激活venv时权限被拒绝 [英] Permission denied when activating venv

查看:744
本文介绍了激活venv时权限被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚启动了一个新的python项目,并通过在终端中运行virtualenv venv在项目文件夹中创建了一个venv.但是,当我运行venv/bin/activate时,出现权限被拒绝错误.

I just started a new python project and created a venv inside the project folder by running virtualenv venv in the terminal. However, when I run venv/bin/activate I get a permission denied error.

我尝试过

sudo chown -R user:user project/venv

但我明白了

chown: user: illegal group name

我已经将这些静脉设置了无数次,但从未出现过问题.还有什么我可以尝试的吗?

I have set these venvs up a ton of times and never had the issue. Is there anything else I can try?

我在Mac上.

推荐答案

您需要运行

. venv/bin/activate

source venv/bin/activate

activate文件是故意不可执行的,因为它必须是源文件.

The activate file is deliberately not executable because it must be sourced.

必须将其来源,因为它需要对环境进行更改.如果将其作为脚本运行,则只会更改用于运行脚本的子进程的环境.

It must be sourced because it needs to make changes to the environment. If it is run as a script, it will only make changes to the environment of the child process used to run the script.

有人在评论中问到.命令.从 bash手册页:

Someone in the comments asked about the . command. From the man page for bash:

    .  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,与source内置的含义相同.

In short, . is a shell built-in that means the same thing as the source built-in.

这篇关于激活venv时权限被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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