Broken references in Virtualenvs

前端 未结 26 1100
一整个雨季
一整个雨季 2020-11-27 08:53

I recently installed a bunch of dotfiles on my Mac along with some other applications (I changed to iTerm instead of Terminal, and Sublime as my default text editor) but eve

相关标签:
26条回答
  • 2020-11-27 09:28

    I was facing the same issue after upgrading brew on my OSX Catalina.

    After trying bunch of stuffs, I find the following is the best and easy solution.

    At first, delete the virtual env. (Optional)

    find myvirtualenv -type l -delete
    

    then recreate a new virtualenv

    virtualenv myvirtualenv
    

    Reference: https://www.jeremycade.com/python/osx/homebrew/2015/03/02/fixing-virtualenv-after-a-python-upgrade/

    0 讨论(0)
  • 2020-11-27 09:30

    A update version @Chris Wedgwood's answer for keeping site-packages (keeping packages installed)

    cd ~/.virtualenv/name_of_broken_venv
    
    
    mv lib/python2.7/site-packages ./    
    rm -rf .Python bin lib include
    virtualenv .
    rm -rf lib/python2.7/site-packages
    mv ./site-packages lib/python2.7/
    
    0 讨论(0)
  • 2020-11-27 09:30

    If you've busted python3 just try brew upgrade python3 that fixed it for me.

    0 讨论(0)
  • 2020-11-27 09:32

    If this was caused by a brew upgrade that upgraded its Python, and you're ok with downgrading to the previous version, try brew switch python [previous version], eg brew switch python 3.6.5. From here.

    0 讨论(0)
  • 2020-11-27 09:32

    virtualenvwrapper instructions

    As indicated in the accepted answer, the root cause is likely a homebrew update that means your virtualenv symlinks are pointing at broken python paths - see details here.

    For each virtual env, you need to reassign the symlinks to point at the correct python path (in brew cellar). Here is how to do it with virtualenvwrapper. Here I am updating a virtual env called "my-example-env".

    cd ~/PYTHON_ENVS
    find ./my-example-env -type l -delete
    mkvirtualenv my-example-env
    

    All done.

    0 讨论(0)
  • 2020-11-27 09:33

    I had a broken virtual env due to a Homebrew reinstall of python (thereby broken symlinks) and also a few "sudo pip install"s I had done earlier. Weizhong's tips were very helpful in fixing the issues without having to reinstall packages. I also had to do the following for the mixed permissions problem.

    sudo chown -R my_username lib/python2.7/site-packages

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