Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Site packages in Python

Tags:

python

So I have two sitepackage folders:

  1. Under: /Library/Python/2.6/site-packages

  2. Under: /Library/Python/2.6/site-packages /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages

Every time I do sudo easy_install module, Python installs it in (1). Every time I try to import it from (1), Python can't find it.

Every time I move that module with copy and paste to (2), Python can find it.

Is there an elegant/regular way to make Python install it in the correct sitepackages?

like image 680
digit Avatar asked Nov 17 '11 09:11

digit


People also ask

What are Python site-packages?

site-packages is the target directory of manually built Python packages. When you build and install Python packages from source (using distutils, probably by executing python setup.py install ), you will find the installed modules in site-packages by default.

Where is site-packages in Python?

Default value is ~/. local/lib/pythonX.Y/site-packages for UNIX and non-framework macOS builds, ~/Library/Python/X.Y/lib/python/site-packages for macOS framework builds, and %APPDATA%\Python\PythonXY\site-packages on Windows.

How do I create a site package in Python?

First, we create a directory and give it a package name, preferably related to its operation. Then we put the classes and the required functions in it. Finally we create an __init__.py file inside the directory, to let Python know that the directory is a package.


1 Answers

Add /Library/Python/2.6/site-packages to your PYTHONPATH.

like image 89
Bertrand Marron Avatar answered Oct 02 '22 14:10

Bertrand Marron