Issue
First of all I am pretty new to setting up virtual env so I can run a Python rest api on it . :)
I installed the virtual env. in the /var
folder of my Ubuntu server with
sudo python3 -m venv project_env
.
After activating the environment I tried to install Flask with following command: (project_env) mStege@homeserver:/var$ pip install Flask
I get this error:
ERROR: Could not install packages due to an EnvironmentError:
[Errno 13] Permission denied: '/var/project_env/lib/python3.8/site-packages/itsdangerous-2.0.1.dist-info' Consider using the `--user` option or check the permissions.
After some research I tried following command to install Flask: pip3 install Flask --user
Which give me this error:
ERROR: Can not perform a '--user' install. User site-packages are not visible in this virtualenv.
Has it something to do where I installed the virtual enviroment?
I didn't put it in my homedir because there is a project-related website in the var
folder and I want everything in one place. Also, there will be some other dudes I will be working with and I thought that it is quite suboptimal when they have to go through my home folder.
Solution
Don't create your virtual environment (venv) in /var
.
My advice:
- Create your virtual environment alongside your source code, if you're using
pip
- If you're using
pipenv
, let pipenv choose where to create the venv
Each one of your colleagues should have their own venv. You can syncronize your environments by using a requirements.txt
(or a Pipfile) to specify which packages and versions are needed.
Answered By - Be Chiller Too