简体   繁体   English

我如何正确使用virtualenv与Anaconda?

[英]How do I properly use virtualenv with Anaconda?

I am on OSX and I have two virtual environments setup for Python 2.7 and 3.x 我在OSX上,我有两个用于Python 2.7和3.x的虚拟环境设置

These were installed using homebrew following this guide , which seems to setup my bash environment correctly. 这些是使用本指南的自制软件安装的,这似乎正确地设置了我的bash环境。

I am encountering a brick wall with the anaconda user configuration though. 我遇到了一个带有anaconda用户配置的砖墙。 Here is my user configuration: 这是我的用户配置:

{
    "python_interpreter": "$VIRTUAL_ENV/bin/python",
    "display_signatures": true,
    "pep8_max_line_length": 120,
}

This is my bash output for $VIRTUAL_ENV. 这是$ VIRTUAL_ENV的bash输出。 I am running sublime from my bash terminal. 我从我的bash终端运行崇高。

$ echo $VIRTUAL_ENV
/Users/rpg711/.virtualenvs/python3

This is my sublime console output for a test build using the anaconda build environment: 这是我使用anaconda构建环境进行测试构建的sublime控制台输出:

/bin/bash: /bin/python: No such file or directory

Here it seems to be looking for /bin/python, as if $VIRTUAL_ENV is evaluating to an empty string. 这里好像在寻找/ bin / python,好像$ VIRTUAL_ENV正在评估一个空字符串。

And the final sanity check... everything seems to be fine here: 最后的理智检查......这里的一切似乎都很好:

(python3) $ python --version
Python 3.6.1
(python3) $ which python
/Users/rpg711/.virtualenvs/python3/bin/python

Anyone know what is going on here? 有谁知道这里发生了什么? I might be doing something wrong. 我可能做错了什么。

Sublime project settings override the user config weirdness. Sublime项目设置会覆盖用户配置的怪异。 This is the only way to be sure that each project is being developed with the correct virtual environment interpreter. 这是确保使用正确的虚拟环境解释器开发每个项目的唯一方法。 Still launching sublime from a shell with the virtual environment activated. 仍然在激活虚拟环境的情况下从shell启动sublime。

I used 我用了

"settings": {
        "python_interpreter": "~/.virtualenvs/[envname]/bin/python"
}

As long as the .sublime-project file exists, no issues with anaconda interpreter. 只要.sublime-project文件存在,anaconda解释器就没有问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM