I haven't touched python and virtualenv in a while, and I believe I setup my MBP with virtualenv and pip, but have totally forgotten how this stuff works.
After installing lion, I'm getting this error when I open up a new terminal window:
Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: No module named virtualenvwrapper.hook_loader virtualenvwrapper.sh: There was a problem running the initialization hooks. If Python could not import the module virtualenvwrapper.hook_loader, check that virtualenv has been installed for VIRTUALENVWRAPPER_PYTHON=/usr/bin/python and that PATH is set properly.
Any tips on how to fix this?
Trying:
easy_install eventlet
I got this:
Traceback (most recent call last): File "/usr/local/bin/easy_install", line 5, in <module> from pkg_resources import load_entry_point File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 2607, in <module> parse_requirements(__requires__), Environment() File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 565, in resolve raise DistributionNotFound(req) # XXX put more info here pkg_resources.DistributionNotFound: setuptools==0.6c11
To use the virtual environment you created to run Python scripts, simply invoke Python from the command line in the context where you activated it. For instance, to run a script, just run python myscript.py .
Running virtualenv with interpreter C:\Python37\python.exe Using base prefix 'C:\Python37' New python executable in C:\Users\XXXX\Documents\GitHub\MyProject\venv\Scripts\python.exe Installing setuptools, pip, wheel... done.
I am a complete Python/Virtualenv novice. However, I had the exact same problem and found a solution that worked for me. I believe that this will vary greatly depending upon the way you originally setup Python & Virtualenv.
In my case, the Lion upgrade completely wiped out all contents of my /Library/Python/2.*/site-packages
, but left the now broken executables (which link to the contents of this folder) in /usr/local/bin
. I believe that this is the root cause of the cryptic "No module" import errors.
Reviewing my .bash_history, I had originally used easy_install
to install pip
, and then pip
to install virtualenv
and virtualenvwrapper
. Once I repeated these steps, then I was able to re-enter my old virtual environments which still contained all the packages I had installed on 10.6. Note, however, that 10.6 shipped with Python 2.6 as default. If your packages require Python 2.6, you should change your default Python version to 2.6 first.
Step-by-step:
.bash_profile
). Start a new terminal session.defaults write com.apple.versioner.python Version 2.6
sudo easy_install pip
. It seems as though /Library/Python/2.*/site-packages
now requires administrator privileges. I don't recall that being the case in 10.6 (or at least my bash history doesn't reflect that).sudo pip install virtualenv
sudo pip install virtualenvwrapper
pip freeze -l
to see local packages in this virtual environment). I think.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With