为什么我无法使用'source env / bin / activate'命令激活我的虚拟Python环境?

时间:2010-10-02 01:30:56

标签: python pylons

我正在尝试激活我的虚拟Python环境以与Pylons一起使用,但我认为我正在执行错误的命令。

jem@jem-laptop:~$ source env/bin/activate
bash: env/bin/activate: No such file or directory

我做错了什么? 我该怎么办呢?

8 个答案:

答案 0 :(得分:23)

我意识到我必须这样做

jem@jem-laptop:~$ ls
Desktop    examples.desktop  Public           shortener.rb
Documents  Mac4Lin_v1.0      ruby-1.9.1-p378  Templates
Downloads  Music             rubygems-1.3.7   Videos
Dropbox    Pictures          setcolors.vim    virtualenv.py

在这里我们看到virtualenv.py。从这里我只需要

jem@jem-laptop:~$ virtualenv ENV
New python executable in ENV/bin/python
Installing setuptools............done.

然后

jem@jem-laptop:~$ source ENV/bin/activate
(ENV)jem@jem-laptop:~$ deactivate
jem@jem-laptop:~$ 

解决了:)

答案 1 :(得分:4)

在2.7版本中,我使用了这个命令:

`W20150614-11:20:50.527(-7)? (STDERR)     at app\signUp\signUp.js:1:48
W20150614-11:20:50.527(-7)? (STDERR)     at app\signUp\signUp.js:54:3
W20150614-11:20:50.529(-7)? (STDERR)     at E:\work\meteor3\app\merchant\.m
eteor\local\build\programs\server\boot.js:222:10
W20150614-11:20:50.529(-7)? (STDERR)     at Array.forEach (native)
W20150614-11:20:50.529(-7)? (STDERR)     at Function._.each._.forEach (C:\Users\
I\AppData\Local\.meteor\packages\meteor-tool\1.1.3\mt-os.windows.x86_32\dev_bund
le\server-lib\node_modules\underscore\underscore.js:79:11)
W20150614-11:21:03.189(-7)? (STDERR)
W20150614-11:21:03.190(-7)? (STDERR) C:\Users\I\AppData\Local\.meteor\packages\m
eteor-tool\1.1.3\mt-os.windows.x86_32\dev_bundle\server-lib\node_modules\fibers\
future.js:245
W20150614-11:21:03.191(-7)? (STDERR)
throw(ex);
W20150614-11:21:03.191(-7)? (STDERR)
      ^
W20150614-11:21:03.192(-7)? (STDERR) Error: A method named '/merchants/insert' is already defined
W20150614-11:21:03.193(-7)? (STDERR)     at packages/ddp/livedata_server.js:1461
:1
W20150614-11:21:03.193(-7)? (STDERR)     at Function._.each._.forEach (packages/
underscore/underscore.js:113:1)
W20150614-11:21:03.194(-7)? (STDERR)     at [object Object]._.extend.methods (pa
ckages/ddp/livedata_server.js:1459:1)
W20150614-11:21:03.194(-7)? (STDERR)     at [object Object].Mongo.Collection._de
fineMutationMethods (packages/mongo/collection.js:904:1)
W20150614-11:21:03.195(-7)? (STDERR)     at new Mongo.Collection (packages/mongo
/collection.js:209:1)
W20150614-11:21:03.196(-7)? (STDERR)     at app\signUp\signUp.js:1:48
W20150614-11:21:03.196(-7)? (STDERR)     at app\signUp\signUp.js:54:3
W20150614-11:21:03.197(-7)? (STDERR)     at E:\work\meteor3\app\merchant\.m
eteor\local\build\programs\server\boot.js:222:10
W20150614-11:21:03.198(-7)? (STDERR)     at Array.forEach (native)
W20150614-11:21:03.199(-7)? (STDERR)     at Function._.each._.forEach (C:\Users\
I\AppData\Local\.meteor\packages\meteor-tool\1.1.3\mt-os.windows.x86_32\dev_bund

答案 2 :(得分:3)

我通常这样做:

$ cd the_project_dir
$ . bin/activate
(the_project)$ _

无论如何我都需要在项目目录中继续工作。 显然the_project_dir是您创建virtualenv的目录的名称。

答案 3 :(得分:1)

我建议使用virtualenvwrapper。它使virtualenv的工作变得更加简单,特别是如果你有多个virtualenv。

答案 4 :(得分:1)

简单修复:

$ virtualenv env
$ cd env/Scripts/
$ . activate

答案 5 :(得分:0)

在FreeBSD上,我执行了以下操作:

# ls mypienv
# mypienv/bin/activate
mypienv/bin/activate: Permission denied.
# chmod +x mypienv/bin/activate
# mypienv/bin/activate
Missing '}'.

您会看到该脚本不起作用,但是:

# ls mypienv/bin/
activate        activate.fish       easy_install-2.7    pip2.7          python2
activate_this.py    activate.ps1        pip         python          python2.7
activate.csh        easy_install        pip2            python-config       wheel

最终:

# python mypienv/bin/activate_this.py

它奏效了! 附言我是python python verions 2.7的新手

答案 6 :(得分:0)

env/Scripts/activate为我工作。

答案 7 :(得分:0)

对于 Windows,以下对我有用:

C:\.virtualenvs\env\Scripts>activate.bat