Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #93720
| Date | 2015-07-12 07:50 +0200 |
|---|---|
| From | Vincent Vande Vyvre <vincent.vande.vyvre@telenet.be> |
| Subject | Re: Fwd: Python Error: ImportError: No module named ''folder_name’ at Command Prompt |
| References | <CANutusz_o3cQNfoDDqgV=K8fai44rAL6QyCk3z8NC3FRRPNQdg@mail.gmail.com> <mnsarg$mg7$1@ger.gmane.org> <CANutusy8V0s2TLeXA-5S03qmOjtb0Qd7TruTz_U_Yf42JfacMQ@mail.gmail.com> <55A1E620.7070507@udel.edu> <CANutuswvnXt-cuMJhF+QKwmVL4C9VP5Rk71-nmL-PwbnkVH0PA@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.444.1436680979.3674.python-list@python.org> (permalink) |
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 comp.lang.python | Previous | Next | Find similar | Unroll thread
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
csiph-web