我刚刚开始一个新的python项目,并通过在终端中运行virtualenv venv在项目文件夹中创建了一个venv.但是,当我运行venv / bin / activate时,我得到一个权限被拒绝错误.
我努力了
sudo chown -R user:user project/venv
但我明白了
chown: user: illegal group name
我已经将这些venvs设置了很多次,从来没有问题.还有什么我可以尝试的吗?
我在Mac上.
解决方法:
你需要跑
. venv/bin/activate
要么
source venv/bin/activate
故意不能执行激活文件,因为它必须是源文件.
必须采购它,因为它需要对环境进行更改.如果它作为脚本运行,它将只更改用于运行脚本的子进程的环境.
. 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.
简而言之, .是内置的shell,与内置的源代码相同.
标签:python,macos