简体   繁体   English

之间的差异。 venv / bin / activate和./venv/bin/activate

[英]Difference Between . venv/bin/activate and ./venv/bin/activate

all 所有

I have a question about an format that to run shell script I encounter this problem is that I setup a virtual environment 我对运行外壳程序脚本的格式有疑问,我遇到的问题是我设置了虚拟环境

But when I type 但是当我打字

. venv/bin/activate

The code has no problem and run it successfully.But I know the other way to run it using 代码没有问题并且可以成功运行。但是我知道使用另一种方式运行它

 ./venv/bin/activate

the bash prompt an error saying I don't have permission to do that. bash提示错误,提示我无权执行此操作。

I don't know what's the difference between them, any help would be appreciate 我不知道他们有什么区别,任何帮助都将不胜感激

The activate script created by virtualenv isn't actually a standard script for executing anything, but it's something that defines further environment variables to an existing bash session. virtualenv创建的activate脚本实际上不是执行任何操作的标准脚本,但是它可以为现有的bash会话定义更多的环境变量。 Note the comment in that file: 请注意该文件中的注释:

# This file must be used with "source bin/activate" *from bash*
# you cannot run it directly

The . venv/bin/activate . venv/bin/activate . venv/bin/activate is actually a synonym to source venv/bin/activate . . venv/bin/activate实际上是同义词source venv/bin/activate In essence, what virtualenv does is to execute a number of statements in the current shell (sourcing the contents of the file into here), rather than starting a new shell process as if you would execute a binary (ie ./venv/bin/python ). 本质上,virtualenv的作用是在当前 shell中执行许多语句(将文件内容提供到此处),而不是像执行二进制文件一样启动新的shell进程(即./venv/bin/python )。

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

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