I'm tying to create a virtual environment in my mac terminal and I get the following error. Could you please help me how I can fix this?
hangsunkim@Hangs-MacBook-Pro ~ % virtualenv --system-site-packages -p python3 ./venv
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 6, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 3241, in <module>
@_call_aside
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 3225, in _call_aside
f(*args, **kwargs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 3254, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 585, in _build_master
return cls._build_from_requirements(__requires__)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 598, in _build_from_requirements
dists = ws.resolve(reqs, Environment())
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 786, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'zipp>=0.5' distribution was not found and is required by importlib-metadata
macOS Catalina --> Version 10.15.3
python --version --> Python 3.7.7
pip --version --> pip 20.0.2 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)
After a while trying to install virtualenv
and virtualenvwrapper
I figured out how to make them work.
Here is what I did:
brew update && brew upgrade
brew doctor
You should see something like "Your system is ready to brew."
brew install python
# Add user python 3.7 to path
export PATH="/usr/local/opt/python/libexec/bin:$PATH"
pip install virtualenv
pip install virtualenvwrapper
which virtualenvwrapper.sh
) #Virtualwrapper stuff
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Git
source /usr/local/bin/virtualenvwrapper.sh
At this point, we still have the zipp>=0.5' error. So what is the problem? As you see in your traceback, virtualenv is trying to use the python version installed in the system and is in that place where there is no distribution of zipp.
I don't know if it is the best way to fix this but at least I was able to create virtualenvs after this:
sudo su
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python /Users/{your_username}/Desktop/get-pip.py
pip install virtualenv
pip install virtualenvwrapper
mkvirtualenv test