close

[Solved] Permission denied when activating venv

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Permission denied when activating venv in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Permission denied when activating venv Error Occurs?

Today I get the following error Permission denied when activating venv in python.

How To Solve Permission denied when activating venv Error ?

  1. How To Solve Permission denied when activating venv Error ?

    To Solve Permission denied when activating venv Error 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.

  2. Permission denied when activating venv

    To Solve Permission denied when activating venv Error 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.

Solution 1

You need to run

. venv/bin/activate

or

source venv/bin/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.

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.

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

Solution 2

On my VSC, I used these and it worked.

python3 -m venv .venv

source .venv/bin/activate

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read