Forums

Pip having trying to uninstall appdirs while trying to install requirements.txt when deploying

I am trying to deploy my project on pythonanywhere. I have created my virtualenv and activated it but when I try to

"pip install -r requirements.txt"

it says

"Found existing installation: appdirs1.4.2 Uninstalling appdirs-1.4.2:"

and then gets a permission denied error.

What's going on and how do I fix it?

Full error in bpaste: https://bpaste.net/show/a7394c84c672

"pip install --user -r requirements.txt" got around this

if you are using pip install --user, that means that you are not in your virtualenv (ie. your virtualenv is not activated), and you are instead just installing on top of system python libraries.

instead, if you do want to use a virtualenv, make sure you have installed into it, and that any webapp etc is running the python within your virtualenv instead of the python outside of it.

Thanks conrad! That actually helps me understand what was going on.

Putting your virtualenv here "mkvirtualenv --python=/usr/bin/python2.7 myvirtualenv" is how I solved it. Is this the correct approach?

Right. After you do mkvirtualenv, it creates a new virtualenv, and automatically activates it and puts you inside of it for that particular console session. If you are starting a new console, you'd have to do "workon myvirtualenv" to put yourself inside of it again. Equivalently, you have to let the webapp, or file editor know that you want to run within the virtualenv by configuring it.