advice on storing 3rd party modules on my computer
How do you guys go about storing your python modules locally? And how do you then go about referencing them in your python scripts?
Should I do this?
/home/python/modules
And then create a sub-directory for each module, like say the amazon s3 module:
/home/python/modules/amazon-s3/s3.py
Now I have to somehow tell python to l开发者_Go百科ook at these folders for modules, which I think is sys.path somehow?
I usually store my modules in /usr/local/lib/python
for the whole system, and /home/user/lib/python
for the user. That's if they weren't installed via the system package manager. If they were a .deb or .rpm or whatever, they'll probably be placed in /usr/lib/python
, as per the FHS standard, which specifies where different types of files should go on a POSIXish operating system.
Set the PYTHONPATH
environment variable to have local packages be found by the interpreter.
Should I do this?
No.
Install them in site-packages
, just like it says in the documentation.
http://docs.python.org/install/
http://docs.python.org/library/site.html
If you're particularly concerned about managing python modules you'll probably want to look at virtualenv, which lets you setup separate virtual python environments so you can separate out what modules are installed and used.
精彩评论