我创建了一个virtualenv围绕我的项目,但当我尝试激活它时,我不能。 这可能只是语法或文件夹位置的问题,但我现在被难住了。

您可以在下面看到,我创建了virtualenv并将其命名为venv。一切看起来都很好,然后我尝试通过运行source venv/bin/activate来激活它

我想这可能只是与我的系统路径有关,但不确定指向什么(我确实知道如何编辑路径)。我使用的是python 7 / windows操作系统,虚拟环境2.2.x

Processing dependencies for virtualenv
Finished processing dependencies for virtualenv

c:\testdjangoproj\mysite>virtualenv --no-site-packages venv
The --no-site-packages flag is deprecated; it is now the default behavior.
Using real prefix 'C:\\Program Files (x86)\\Python'
New python executable in venv\Scripts\python.exe
File venv\Lib\distutils\distutils.cfg exists with different content; not overwri
ting
Installing setuptools.................done.
Installing pip...................done.

c:\testdjangoproj\mysite>source venv/bin/activate
'source' is not recognized as an internal or external command,
operable program or batch file.

c:\testdjangoproj\mysite>source venv/bin/activate
'source' is not recognized as an internal or external command,
operable program or batch file.

c:\testdjangoproj\mysite>source mysite/bin/activate
'source' is not recognized as an internal or external command,
operable program or batch file.

c:\testdjangoproj\mysite>

当前回答

最终在Windows 10上使用:

activate myvenv

其中myvenv是我想激活的虚拟环境的名称。

基本上,这个命令是:

activate <<your_venv_name>>

祝你一切顺利!

其他回答

如果您使用的是windows,只需运行。\Scripts\activate。注意,反斜杠会起作用!

我有一个地狱的时间在windows上使用virtualenv与git bash,我通常最终明确指定python二进制。

如果我的环境在say .env中,我将通过。/.env/Scripts/python.exe…或在shebang行#!./.env/Scripts/python.exe调用python;

两者都假设工作目录包含virtualenv (.env)。

我在自己的Windows 10电脑上也遇到了同样的问题。 我尝试的步骤是:

去andconda终端 步骤1

pip3 install -U pip virtualenv

步骤2

virtualenv --system-site-packages -p python ./venv

or

virtualenv --system-site-packages -p python3 ./venv

步骤3

.\venv\activate

你可以通过anaconda中的蜘蛛工具输入import tensorflow as tf来检查它

如果你在使用virtualenv yourenvname命令后看到5个文件夹(Include,Lib,Scripts,tcl,pip-selfcheck),将目录更改为cmd本身的Scripts文件夹,并简单地使用“activate”命令。

可以在cygwin终端上执行source命令