Getting a python virtual env error after installing Lion

后端 未结 9 521
情话喂你
情话喂你 2020-12-04 19:44

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 ins

相关标签:
9条回答
  • 2020-12-04 20:16

    Blankman,

    I encountered the same error but my problem in hindsight was straightforward, i am sharing my work around below. YMMV.

    I used (home)brew to install python 2.7.2 and am using it as my default. It is referenced via /usr/local/bin/python. The stock python install that came with Mac OS X Lion is referenced at /usr/bin/python.

    --

    The virtualwrapper.sh startup script checked the environment variable VIRTUALENVWRAPPER_PYTHON and if empty and populated it with '/usr/local/bin/python'. This was the reason for my error. Initializing it to '/usr/local/bin/python' fixed the problem for me.

    HTH.

    To clarify. I installed python 2.7.2 using brew and combine it with virtualenv to better manage my development environments. I try to steer clear of the preinstalled set up as much as I can.

    0 讨论(0)
  • 2020-12-04 20:22

    Have you installed virtualenv for the Python that you are using? If you are using the default Apple-supplied system Python 2.7, it doesn't come with the virtualenv package pre-installed. Use /usr/bin/easy_install to install it.

    UPDATE: Just to be clear, on Lion 10.7, there is now an Apple-supplied Python 2.7 which is the default version when you use /usr/bin/python. Apple continues to also ship a Python 2.6 and a 2.5 in Lion as it did in 10.6 Snow Leopard. You can pick which version you want by explicitly referencing it, as in /usr/bin/python2.7, /usr/bin/python2.6, etc, and you can change the default that /usr/bin/python uses; read the Apple man page (man python) for details. The key point, though, is that, in general, Python packages are installed to a specific version. If you installed something for 2.6, you'll need to install it with python2.7 (or easy_install-2.7) if you want to use it with 2.7.

    0 讨论(0)
  • 2020-12-04 20:26

    yes, after upgrading to marvericks, need to install pip and virtualenv again by using /usr/bin/easy_install.

    0 讨论(0)
  • 2020-12-04 20:27

    My solution on Ubuntu 14.04 where I had installed python3.4 was to add this to the ~/.bashrc file so that the tail of it looked liked this:

    #Setup virtual envwrapper for python in case default doesn't work
    VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3.4
    export VIRTUALENVWRAPPER_PYTHON
    
    # needed for virtualenvwrapper
    export WORKON_HOME=$HOME/.virtualenvs
    export PROJECT_HOME=$HOME/projects
    source /usr/local/bin/virtualenvwrapper.sh
    

    When I did pip freeze on regular python which was 2.7 it showed packages installed correctly but still complained. Even though it complained the virtualenv did work.

    I have later removed the errors by making sure that all the files in the ~/.virtualenvs belong to the user and group rather than a smattering of them to root. Like this:

    bash cd ~ sudo chown -R ubuntu:ubuntu .virtualenvs

    0 讨论(0)
  • 2020-12-04 20:28

    For anyone else who is pulling out there hair... I was getting this same error but only when trying scp (secure copy) to one of my other macs. It took me a while to realize that the message was actually relevant to the Mac I was logging in. For os x .bash_profile runs at login and I wasn't correctly sourcing my .bashrc from the .bash_profile to pick up the environment settings Ned outlines. So make sure these setting are set for the machine you log into as well.

    0 讨论(0)
  • 2020-12-04 20:31

    I received this after upgrading to yosemite. To fix I had to run:

    sudo pip install --upgrade setuptools
    
    0 讨论(0)
提交回复
热议问题