如何激活virtualenv? [英] How to activate virtualenv?

查看:374
本文介绍了如何激活virtualenv?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在搜索,尝试了各种替代方法都没有成功,现在花了几天时间-令我发疯.

I have been through search and tried various alternatives without success and spent several days on it now - driving me mad.

在具有Python 2.5.2的Red Hat Linux上运行 开始使用最新的Virtualenv,但无法激活它,我发现某个地方提示需要较早的版本,因此我使用了Virtualenv 1.6.4,因为它应可与Python 2.6一起使用.

Running on Red Hat Linux with Python 2.5.2 Began using most recent Virtualenv but could not activate it, I found somewhere suggesting needed earlier version so I have used Virtualenv 1.6.4 as that should work with Python 2.6.

[necrailk@server6 ~]$ python virtualenv-1.6.4/virtualenv.py virtual
New python executable in virtual/bin/python
Installing setuptools............done.
Installing pip...............done.

环境看起来还可以

[necrailk@server6 ~]$ cd virtual
[necrailk@server6 ~/virtual]$ dir
bin  include  lib

尝试激活

[necrailk@server6 ~/virtual]$ . bin/activate
/bin/.: Permission denied.

已检查chmod

[necrailk@server6 ~/virtual]$ cd bin
[necrailk@server6 bin]$ ls -l
total 3160
-rw-r--r--    1 necrailk biz12        2130 Jan 30 11:38 activate
-rw-r--r--    1 necrailk biz12        1050 Jan 30 11:38 activate.csh
-rw-r--r--    1 necrailk biz12        2869 Jan 30 11:38 activate.fish
-rw-r--r-

问题,所以我更改了

[necrailk@server6 bin]$ ls -l
total 3160
-rwxr--r--    1 necrailk biz12        2130 Jan 30 11:38 activate
-rw-r--r--    1 necrailk biz12        1050 Jan 30 11:38 activate.csh
-rw-r--r--    1 necrailk biz12        2869 Jan 30 11:38 activate.fish
-rw-r--r--    1 necrailk biz12        1005 Jan 30 11:38 activate_this.py
-rwxr-xr-x    1 necrailk biz

再试一次activate

[necrailk@server6 ~/virtual]$ . bin/activate
/bin/.: Permission denied.

仍然没有喜悦...

推荐答案

这是创建文件夹并cd进入其中之后的工作流程:

Here is my workflow after creating a folder and cd'ing into it:

$ virtualenv venv --distribute
New python executable in venv/bin/python
Installing distribute.........done.
Installing pip................done.
$ source venv/bin/activate
(venv)$ python

这篇关于如何激活virtualenv?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆