Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #93720 > unrolled thread
| Started by | Vincent Vande Vyvre <vincent.vande.vyvre@telenet.be> |
|---|---|
| First post | 2015-07-12 07:50 +0200 |
| Last post | 2015-07-12 07:50 +0200 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Fwd: Python Error: ImportError: No module named ''folder_name’ at Command Prompt Vincent Vande Vyvre <vincent.vande.vyvre@telenet.be> - 2015-07-12 07:50 +0200
| From | Vincent Vande Vyvre <vincent.vande.vyvre@telenet.be> |
|---|---|
| Date | 2015-07-12 07:50 +0200 |
| Subject | Re: Fwd: Python Error: ImportError: No module named ''folder_name’ at Command Prompt |
| Message-ID | <mailman.444.1436680979.3674.python-list@python.org> |
Le 12/07/2015 06:02, Ernest Bonat, Ph.D. a écrit :
> Thanks for your help. I had follow the link: How to add a Python module
> to syspath?
>
> <http://askubuntu.com/questions/470982/how-to-add-a-python-module-to-syspath>
> and I could not make it work. I did use sys.path.insert() and
> sys.path.append() as:
>
> Examples: sys.path.append('/python_mvc_calculator/calculator/') or
> sys.path.insert(0, "/python_mvc_calculator/calculator")
>
> I did try it to:
> sys.path.append('/python_mvc_calculator/calculator/controller') or
> sys.path.insert(0, "/python_mvc_calculator/calculator/controller") too!
>
> The main.py file is in python_mvc_calculator/calculator folder and I
> need to import a module calculatorcontroller.py in
> "python_mvc_calculator/calculator/controller"
>
> I hope this explanation helps a bit!
>
> <http://askubuntu.com/questions/470982/how-to-add-a-python-module-to-syspath>
>
> Thanks
>
If "/python_mvc_calculator/calculator/controller" is a folder and if you
have a file __init__.py into this folder, you have to use:
sys.path.insert(0, "/python_mvc_calculator/calculator/controller")
from calculatorcontroller import foo # or import calculatorcontroller
But the init file must be named __init__.py NOT init.py as sayed in
askubuntu.
Vincent
Back to top | Article view | comp.lang.python
csiph-web