[SciPy-User] ubuntu's PYTHONPATH and installing scipy
Fri Dec 11 17:17:48 CST 2009
i had this same problem when trying to use my own built-from-scratch
numpy while still needing system numpy as dependency.
In debian, /usr/lib/pythonX.Y/dist-packages will appear on sys.path
BEFORE /usr/local/lib/pythonX.Y/dist-packages (which is where I
install my source-built stuff).
I solved this by creating a $HOME/.local/lib/pythonX.Y/site-packages
directory (which WILL be on sys.path before the others) and inserting
a .pth file with my local directory. Since this dir is searched by
python before /usr/lib/... it reads the .pth file and thus adds my
local dir to sys.path before anything else.
I found this a cleaner solution than editing .bashrc or any other
variant because those only work when your in a shell environment.
On Wed, Dec 9, 2009 at 5:41 PM, Darren Dale <email@example.com> wrote:
> On Wed, Dec 9, 2009 at 2:06 AM, Charles R Harris
> <firstname.lastname@example.org> wrote:
>> On Tue, Dec 8, 2009 at 6:31 PM, Darren Dale <email@example.com> wrote:
>>> On Tue, Dec 8, 2009 at 7:10 PM, John Schulman <firstname.lastname@example.org> wrote:
>>> > Hi,
>>> > There's an issue with ubuntu PYTHONPATH that causes problems for scipy
>>> > installation. I eventually found a workaround, but I want to point out
>>> > the problem.
>>> > PYTHONPATH is different when sudoing, so that packages installed by
>>> > aptitute appear first in the path.*
>>> > The svn version scipy imports numpy in the setup script. "python
>>> > setup.py build" works as it should, but then "sudo python setup.py
>>> > install" gives the error "ImportError: cannot import name get_info",
>>> > since it's trying to use numpy1.3 (which was a dependency for some
>>> > package I installed).
>>> > The workaround is simple:
>>> > sudo PYTHONPATH=/usr/local/lib/python2.6/dist-packages: python setup.py
>>> > install
>>> > *In ubuntu, packages that you install through the apt package manager
>>> > goes into /usr/lib/python2.6/dist-packages, but python setup.py
>>> > install puts stuff in /usr/local/lib/python2.6/dist-packages. There's
>>> > a line in /etc/profile (I didn't put it there--it must be Ubuntu):
>>> > export PYTHONPATH=/usr/local/lib/python2.6/dist-packages:$PYTHONPATH.
>>> > I guess this is a kludge to fix the problem.
>>> You can also use visudo to edit your sudo options, so that your
>>> PYTHONPATH is carried over.
>> Oh, that's too clever. I used locate to find all the numpy installations and
>> deleted those with the wrong date ;) There are actually *three* different
>> directories in which python stuff gets installed. I haven't a clue why.
> Debian's python policy is described at
> http://www.debian.org/doc/packaging-manuals/python-policy/ , but I
> don't think that page reflects changes in debian unstable/ubuntu. I
> don't understand the reason for using dist-packages instead of
> site-packages. And now manually installed packages go into /usr/local
> instead of /usr, but recently they changed things so /usr appears
> higher in the python search path, so it is difficult to manually
> upgrade software provided by the package manager. Maybe the
> debian/ubuntu maintainers were trying to make it more difficult for
> users to break packages installed by the package manager? In my
> opinion, the policy is in unintuitive and in the way.
> SciPy-User mailing list
More information about the SciPy-User