Getting a python virtual env error after installing Lion

后端 未结 9 522
情话喂你
情话喂你 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:32

    I had to reinstall setup-tools (in this case, the Python 2.7 egg for Mountain Lion), and then I was able to reinstall pip, and then virtualenv.

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

    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:

    1. I removed old Virtualenv configuration commands from my shell startup scripts (eg., .bash_profile). Start a new terminal session.
    2. (optional) Choose the version of Python you wish to use, eg.,
      defaults write com.apple.versioner.python Version 2.6
    3. 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).
    4. sudo pip install virtualenv
    5. sudo pip install virtualenvwrapper
    6. Finally, I re-enabled those virtualenv configuration commands I disabled in step 1. A new terminal session had everything back the way it was (look at pip freeze -l to see local packages in this virtual environment). I think.
    0 讨论(0)
  • 2020-12-04 20:40

    To fix the second problem you should reinstall setuptools.

    And to fix the first one, just install virtualenvwrapper with that.

    Basically, when you install Lion, you'll have to reinstall all your python site-packages.

    0 讨论(0)
提交回复
热议问题