Question

I am currently facing an issue when trying to install Django using pythonbrew.

My system is running ubuntu 12.04 (LTS) and I am following these instructions to get django running:

http://www.tangowithdjango.com/book/chapters/requirements.html#installing-software

I have followed everything exactly as specified by the book but when it comes time to use Django on my pythonbrew version of Python, I get this error:

Traceback (most recent call last): File "", line 1, in ImportError: No module named django

So I decided to do some investigating and I went into the folder that is now specified as my PYTHONPATH for adding additional libraries, which is:

./.pythonbrew/pythons/Python-2.7.5/lib/python2.7/site-packages (I've left out the above 2 folder levels, but my PYTHONPATH is correct, confirmed by echo $PYTHONPATH)

In the site-packages folder, there is nothing there, which explains the Django error.

So I switched off pythonbrew and then ran python and then 'import django' and it worked.

This likely means that when trying to install stuff to Python, it is probably not using the PYTHONPATH for some reason (or maybe something else).

I have taken a look here:

1) Error after installing Django (supposed PATH or PYTHONPATH "error") (the solution and question seems very different to mine, with slight similarities)

2) how to install additional python packages with pythonbrew (the guy didn't get a response and did a hack)

3) http://suvashthapaliya.com/blog/2012/01/sandboxed-python-virtual-environments/ (this guy recommends using virtualenv to create a virtual environment before installing packages)

I'm not sure what to do now and I suspect the error is either with my PYTHONPATH or there's some permission error that is causing all my installed packages to go to the root python installation instead of the pythonbrew package.

Any assistance will be greatly appreciated (also, this isn't a unique problem, as I expect many others to face this installation issue with pythonbrew and django).

Was it helpful?

Solution

I'm new in Stack Overflow, so I couldn't comment on your answer above about what you got when running

pip -V

I had the same issue, but I fix it by doing what this post says:

Using pip in pythonbrew

Hope this helps!

OTHER TIPS

Try this (in command-line):

source "/home/user/.pythonbrew/etc/bashrc"

Make sure you changed path /home/user/.pythonbrew to your pythonbrew path. Then ensure you have the right pip:

pip -V

an output should be something like that:

pip 1.4.1 from /home/user/.pythonbrew/pythons/Python-2.7.5/lib/python2.7/site-packages/pip-1.4.1-py2.7.egg (python 2.7)

then install Django with

pip install -U django==1.5.4

First command make pip work only for current terminal. If you want to make usage of pythonbrew's pip persistent, you can add this line to your .bashrc:

. /home/user/.pythonbrew/etc/bashrc
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top