问题
Well, looking around here there are tons of questions about how to correctly installing virtualenvwrapper on Mac. I really tried all of them but for no avail. I've noticed the previous questions don't have the configuration like my computer, so here it is:
- Mac OS Sierra 10.12
- Python3.5.2 installed from python.org installer for Mac OS
- This installation puts Python3.5.2 in this path:
/Library/Frameworks/Python.framework/Versions/3.5/bin/python3
- I've run
python3 get-pip.py
command to installpip
correctly, as I think sudo pip3 virtualenvwrapper
to be sure all settings will be done as they should- As the documentation says, edited
~/.bash_profile
with the code below:export WORKON_HOME=$HOME/.virtualenvs export PROJECT_HOME=$HOME/projects source /usr/local/bin/virtualenvwrapper.sh
Then, whenever I open a new fresh Terminal, I got this:
/usr/bin/python: No module named virtualenvwrapper virtualenvwrapper.sh: There was a problem running the initialization hooks. If Python could not import the module virtualenvwrapper.hook_loader, check that virtualenvwrapper has been installed for VIRTUALENVWRAPPER_PYTHON=/usr/bin/python and that PATH is set properly.
I've tried the fixes from others questions, to no avail:
- set
VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3
on virtualenvwrapper.sh - set
VIRTUALENVWRAPPER_PYTHON="$(command \which python3)"
on virtualenvwrapper.sh ln -fs /Library/Frameworks/Python.framework/Versions/3.5/bin/python3 /usr/local/bin/python3
alias python=/usr/local/bin/python3
Well, looking forward to anyone with a configuration like mine to see what I'm doing wrong.
回答1:
This is pretty old, but posting this because I came here from google and finally figured out the right paths.
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6
export PROJECT_HOME=$HOME/Devel
source /Library/Frameworks/Python.framework/Versions/3.6/bin/virtualenvwrapper.sh
You have to make sure to have the actual python executable. This can be found by just simply browsing in Finder through to /bin and seeing what is there.
回答2:
Well, after a lot of effort, I've decided to install pip
and virtualenvwrapper
on Python 2.7 shipped in macOS Sierra.
After that, I wrote the lines below on .bash_profile
. Maybe there's something redundant here but, it works.
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Documents/Projects/
ln -fs /Users/myusername/Library/Python/2.7/bin/virtualenvwrapper.sh /usr/local/bin/virtualenvwrapper.sh
ln -fs /Users/myusername/Library/Python/2.7/bin/virtualenv /usr/local/bin/virtualenv
source /usr/local/bin/virtualenvwrapper.sh
After that, I've installed Python 3.5.2 from python.org and created a new enviroment pointing to it and everything is working just fine.
mkvirtualenv --python=python3.5 env_name
来源:https://stackoverflow.com/questions/40732423/how-to-definitely-install-virtualenvwrapper-with-python3-5-on-mac-os-sierra