Skip to content Skip to sidebar Skip to footer

Pip Install Error Within Python 3 Virtualenv

I created a Python 3 virtualenv, like this: mkproject -p python3 flowerid But when I try to install anything with pip (inside this virtualenv) I get this error: cd flowerid pip in

Solution 1:

Ok, I figured it out. It was my environmental variable PYTHONPATH - that was messing things up - telling Python to look in the Python 2.7 libraries... I am setting up my PYTHONPATH in my .bashrc.

So the solution is to change the PYTHONPATH on activation and setting back the previous setting on deactivation (it boggles my mind a bit that this is not default...)

So in /Users/nicolas/.virtualenvs/flowerid/bin/activate add:

# Fix PYTHONPATH importsexport OLD_PYTHONPATH="$PYTHONPATH"export PYTHONPATH="/Users/nicolas/.virtualenvs/flowerid/lib/python3.6/site-packages/"

And in /Users/nicolas/.virtualenvs/flowerid/bin/postdeactivate:

# Reset PYTHONPATH to previous stateexport PYTHONPATH="$OLD_PYTHONPATH"

Here's where I found out what the problem was: virtualenv --no-site-packages and pip still finding global packages?

And the solution: How do you set your pythonpath in an already-created virtualenv?

Solution 2:

Try replacing the line in /Library/Python/2.7/site-packages/concurrent/futures/_base.py

raisetype(self._exception), self._exception, self._traceback

with this

    raise Exception(self._exception), self._exception, self._traceback

Solution 3:

Try using pip3 instead of pip command. Since you are using python 3.

Post a Comment for "Pip Install Error Within Python 3 Virtualenv"