I recently move my python virtual environments to a different location. I first encountered the problem of certain packages being unavailable when I activated the venv. Now I get "Permission denied" on everything.
I changed every occurence of the previous path, in every file in the venv directory, to the new one so the sha-bangs would no longer be a problem. They don't seem to be anymore.
Previous questions related to this topic have mentioned the ownership of the directory as the potential problem. I am using an ubuntu machine and I am not very knowledgeable about Linux but when I ll these directories I can see that I own them. (the result of whoami anyway).
Problems only arose once I moved the venv directory. So I don't think it is related to the installing with sudo stuff that I also read about.
Any ideas? your help is hugely appreciated.
This is most likely a linux file permissions issue, as you mention yourself
You can view the permissions on your files using ls -l
This will list the files in your current directory in "long" format.
eg:
ls -l
drwxr-xr-x. 4 root root 68 Jun 13 20:25 tuned
-rw-r--r--. 1 root root 4017 Feb 24 2022 vimrc
To make sure you have the correct permissions you need to follow two steps:
Note that we are going to do this for the main directory of your project.
Step 1: Change ownership
you can change ownership of everything using this command:
sudo chown -R user directory
Replace user
with your username (as returned by whoami
)
Replace directory with your project directory`
-R
means this is recursive and will affect all the subfiles and subdirectories.
Step 2: Change permissions of the file
you can change the access permissions using this command:
sudo chmod -R 755 directory
Replace directory
with your project directory
-R
means this is recursive and will affect all the subfiles and subdirectories.
755 is a permissions code. It stands for
Once you've done this, you can check permissions again using ls -l
.
This will have changed permissions on all your subdirectories, including the files in your virtual environment.