PYTHONPATH: dev and prod

rusi rustompmody at gmail.com
Tue Jun 11 13:14:43 EDT 2013


On Jun 11, 9:28 pm, jacopo <jacopo.pe... at gmail.com> wrote:
> I am developing my code in the path:
> /py/myscripts
> /py/mylib
> In order to "import mylib", I need to add /py/mylib to PYTHONPATH.
>
> Now I want to save a snapshot of the current code in the production directory, I will copy all in:
> /prod/myscripts
> /prod/mylib
>
> The problem now is that when I execute /prod/myscripts/any_script.py, every "import" will look at PYTHONPATH and therefore it will load the modules from /py/mylib. On the contrary I want to load it from /prod/mylib.
>
> Is there an elegant way to cope with this?
>
> thanks, Jacopo

<I-think>
Use explicit (dot-based) relative imports
http://docs.python.org/release/2.5/whatsnew/pep-328.html
Avoid using PYTHONPATH
</I-think>



More information about the Python-list mailing list