【问题标题】:mkvirtualenv running without error but not creating the environment in zshmkvirtualenv 运行没有错误,但没有在 zsh 中创建环境
【发布时间】:2020-05-05 16:24:57
【问题描述】:

我正在 Mac (Catalina) 上过渡到 zsh。到目前为止一切顺利,除了我的 virtualenv 和 virtualenvwrapper 没有按预期工作。我已经尝试使用以下步骤重新安装:

rm -rf ~/.virtualenvs  # Delete all existing data.
pip uninstall virtualenv virtualenvwrapper # Remove
pip install virtualenv virtualenvwrapper # Reinstall

在 ~/.zshrc 中添加了以下几行

export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python2.7
export WORKON_HOME="${HOME}/.virtualenvs"
source `which virtualenvwrapper.sh`

我现在可以访问 zsh 中的命令了。但是如果我尝试使用以下方法制作环境: mkvirtualenv testenv 我明白了:

Using base prefix '/Library/Frameworks/Python.framework/Versions/3.7'
New python executable in /Users/alesirowland/.virtualenvs/bin/python3.7
Not overwriting existing python script /Users/alesirowland/.virtualenvs/bin/python (you must use /Users/alesirowland/.virtualenvs/bin/python3.7)
Installing setuptools, pip, wheel...
done.

运行lsvirtualenv 不会返回任何环境。尽管我的环境变量默认为 python2.7,但它似乎也在尝试使用 3.7。回到我的 bash 控制台会创建环境,但也默认为 python3。我做错了什么?

编辑: 详细输出通常要求安装在 ~/.virtualenvs/bin 而不是 ~/.virtualenvs//bin 在现有环境上工作只会将我所有的环境回显到屏幕上。

【问题讨论】:

  • 提示:您可以只写source =virtualenvwrapper.sh 而不是显式调用which
  • 另外,您是否在编辑后获取了.zshrc?将环境修改放在 .zprofile 中也是更好的做法,因为它们可以被子 shell 继承,而不是每次都需要在 .zshrc 中显式(重新)设置。
  • 我在编辑后做了 source .zshrc。

标签: python virtualenv zsh virtualenvwrapper


【解决方案1】:

找到解决方案!我的 .zshrc 中的这一行由于某种原因影响了 virtualenvwrapper setopt KSHARRAYS

【讨论】:

    猜你喜欢
    • 2019-12-06
    • 2012-05-05
    • 2015-10-16
    • 1970-01-01
    • 1970-01-01
    • 2013-12-17
    • 2021-12-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多