Reputation: 7319
After a restart of my machine, I can see virtualenv is failing to setup when my login scripts are invoking it.
My .bashrc contains
export WORKON_HOME=~/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
And the error looks like
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Library/Python/2.7/site-packages/virtualenvwrapper/hook_loader.py", line 12, in <module>
import optparse
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/optparse.py", line 77, in <module>
import textwrap
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/textwrap.py", line 32, in <module>
class TextWrapper:
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/textwrap.py", line 74, in TextWrapper
whitespace_trans = string.maketrans(_whitespace, ' ' * len(_whitespace))
AttributeError: 'module' object has no attribute 'maketrans'
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.
As far as I can tell, the items alluded to in the error message look okay,
ytestpythonapp$ls /Library/Python/2.7/site-packages/
README pip-1.1-py2.7.egg virtualenv.py virtualenv_support virtualenvwrapper-3.2-py2.7-nspkg.pth
easy-install.pth virtualenv-1.7.1.2-py2.7.egg-info virtualenv.pyc virtualenvwrapper virtualenvwrapper-3.2-py2.7.egg-info
and
mytestpythonapp$ls /usr/local/bin/ | grep vir
virtualenv
virtualenvwrapper.sh
and
mytestpythonapp$echo $PATH
/Users/markdsievers/.virtualenvs/mytestpythonapp/bin:/usr/local/bin:/Users/markdsievers/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/mongodb/bin:/usr/local/cmd:/usr/local/sbin:
I'm fairly new to Python but have had virualenv working for a couple weeks now over many restarts, so I'm pretty puzzled by all of this. Any pointers much appreciated.
OSX Lion, Python 2.7
Upvotes: 2
Views: 1058
Reputation: 657
It's possible that you have a file in your base directory that is conflicting with a python module name, i.e. string.py
Upvotes: 2