我已经在 Ubuntu 16.04 上安装了 python 3.6。
me@server:~/sites/mysite.org/virtualenv/bin$ ll
total 20
drwxrwxr-x 2 me me 4096 May 4 11:45 ./
drwxrwxr-x 5 me me 4096 May 4 11:45 ../
-rw-rw-r-- 1 me me 2172 May 4 11:45 activate
-rw-rw-r-- 1 me me 1288 May 4 11:45 activate.csh
-rw-rw-r-- 1 me me 2452 May 4 11:45 activate.fish
lrwxrwxrwx 1 me me 9 May 4 11:45 python -> python3.6*
lrwxrwxrwx 1 me me 9 May 4 11:45 python3 -> python3.6*
lrwxrwxrwx 1 me me 37 May 4 11:45 python3.6 -> /home/me/miniconda3/bin/python3.6*
me@server:~/sites/mysite.org/virtualenv/bin$ cd ..
me@server:~/sites/mysite.org/virtualenv$ source /bin/activate
-bash: /bin/activate: No such file or directory
me@server:~/sites/mysite.org/virtualenv/bin$ ll
total 20
drwxrwxr-x 2 me me 4096 May 4 11:45 ./
drwxrwxr-x 5 me me 4096 May 4 11:45 ../
-rw-rw-r-- 1 me me 2172 May 4 11:45 activate
-rw-rw-r-- 1 me me 1288 May 4 11:45 activate.csh
-rw-rw-r-- 1 me me 2452 May 4 11:45 activate.fish
lrwxrwxrwx 1 me me 9 May 4 11:45 python -> python3.6*
lrwxrwxrwx 1 me me 9 May 4 11:45 python3 -> python3.6*
lrwxrwxrwx 1 me me 37 May 4 11:45 python3.6 -> /home/me/miniconda3/bin/python3.6*
me@server:~/sites/mysite.org/virtualenv/bin$ cd ..
me@server:~/sites/mysite.org/virtualenv$ source /bin/activate
-bash: /bin/activate: No such file or directory
我无法激活虚拟环境。我认为这很可能是基于权限的。这是正确的吗?如果是这样,有没有办法在创建虚拟环境时设置权限,以便它能够正常工作?
答案1
根据您的输出,您找不到/bin/activate
文件~/sites/mysite.org/virtualenv/bin/activate
的实际位置。
如果你在~/sites/mysite.org/virtualenv/
目录中,你可以像这样运行它:
source ./bin/activate
或者
source bin/activate
但请注意,在我的示例中我没有从 开始,/
因为那意味着从 Linux 文件系统的根目录开始。