Python Virtualenv Set Up with Google App Engine Problems

1. Import Error: from google import appengine.api

Python is already installed in the virtualenv. Google App Engine SDK was also installed and have made symlinks. But it keep having this Import Error. The reason is that there may be several different versions of Python in the mac (The locations of Python is mentioned later) , the one Google App Engine linked to is not the same one as that I was using in the virtualenv. By setting the PATH and PYTHONPATH to have /usr/local/google_appengine is not useful either. What I have done was very violent. I cleared all the pythons and reinstall it and set up the virtualenv again. It solved the error.

2. Ways to uninstall python in Mac OSX

a. Don’t uninstall Apple’s python !!! It will mess you up with python environment, and is very hard to reset. Probably need to re-install OS X… Good luck

b. Uninstall python install with Homebrew: brew uninstall python

c. Uninstall python installed by other methods, e.g. downloading from official website:

Very good post to understand the difference of the three

3. -bash: pip: command not found

sudo easy_install pip runs successfully, pip is install. But when I did pip, it had that error -bash: pip: command not found. This is due to I deleted Apple’s python in /System/Library/Frameworks/Python.framework/Versions/2.7. Upgraded the system and Apple’s Python2.7 is back. Run sudo easy_install pip again, it is solved.

4. -bash: /usr/local/bin/virtualenv: /usr/local/opt/python/bin/python2.7: bad interpreter: No such file or directory

uninstall and reinstall virtualenv. sudo pip uninstall virtualenv. sudo pip install virtualenv

Things to note, make sure you have /usr/local/google_appengine in your PATH before setting up the virtualenv. if not do this export PATH=$PATH:/usr/local/google_appengine.

Some other solutions I didn’t try:

Good to know: /usr/bin/python vs /opt/local/bin/python2.7 on OS X: