I’m guessing my question is pretty basic, but after 15-20 minutes on Google and YouTube, I am still a little fuzzy. I am relatively new to both Linux and Python, so I am having some difficulty comprehending the file system tree (coming from Windows).
From what I’ve found digging around the directories in Ubuntu (which is version 12.04, I believe, which I am running in VBox), I have ID’d the following two directories related to Python:
-
/usr/local/lib/python2.7which contains these two subdirectories:dist-packages
site-packagesboth of which do not show anything when I type “ls” to get a list of the files therein, but show “. ..” when I type “ls -a”.
-
/usr/lib/python2.7which has nosite-packagesdirectory but does have adist-packagesdirectory that contains many files and subdirectories.
So if I want to install a 3rd party Python module, like, say, Mechanize, in which one of the above directories (and which subdirectory), am I supposed to install it in?
Furthermore, I am unclear on the steps to take even after I know where to install it; so far, I have the following planned:
- Download the tar.gz (or whatever kind of file the module comes in) from whatever site or server has it
- Direct the file to be unzipped in the appropriate subdirectory (one of the 2 listed above)
- Test to make sure it works via
import mechanizein interactive mode.
Lastly, if I want to replace step number 1 above with a terminal command (something like sudo apt-get), what command would that be, i.e., what command via the terminal would equate to clicking on a download link from a browser to download the desired file?
virtualenvis the de facto Python standard for installing third party library cleanly. Read more about it here:http://www.virtualenv.org/
Usage example:
On Ubuntu, install virtualenv via
apt-get install python-virtualenv