擅长:python、mysql、java
<p>你得跑了</p>
<pre><code>. venv/bin/activate
</code></pre>
<p>或者</p>
<pre><code>source venv/bin/activate
</code></pre>
<p><code>activate</code>文件故意不可执行,因为它必须是源文件。</p>
<p>它必须是源代码,因为它需要对环境进行更改。如果它作为脚本运行,它将只对用于运行脚本的子进程的环境进行更改。</p>
<p>评论中有人问起<code>.</code>命令。从<a href="https://linux.die.net/man/1/bash" rel="noreferrer">man page for bash</a>:</p>
<pre><code> . filename [arguments]
source filename [arguments]
Read and execute commands from filename in the current shell
environment and return the exit status of the last command
executed from filename.
</code></pre>
<p>简而言之,<code>.</code>是一个内置的shell,其含义与内置的<code>source</code>相同。</p>