After creating python virtual environment virtualenv -p python3 venv and activating it source venv/bin/activate, i am trying to install python packages using pip command-> pip install Flask which throws permission errors:

Could not install packages due to an EnvironmentError: [Errno 13] 
Permission denied: '/var/www/flask/apnisi/venv/lib/python3.5/site-packages/werkzeug'

After adding sudo to pip command sudo pip install Flask installation is successful; however, when i pip list installed packages it doesn't show newly installed ones. What could be the problem?

1 Answer 1


You are likely encountering issues as it does not appear that you have "sourced" your environment correctly if what you have posted is accurate. I also recommend that you specify what version of python you are using to avoid issues with compatibility when you have both python2 and python3. If this is not the case, please edit your question and this answer can be removed or edited in turn.

The basics of creating a python 3 virtual environment are:

python3 -m venv /path/to/virtual/env
source ./path/to/virtual/env/bin/activate

You may need to install venv first (apt install python3-venv) and remember that your path and virtual environment itself has to be a place your user has permission to write to. At this point you should be in your virtual environment ((env) user@host:~$ _).

You should not need sudo with pip. Using sudo with pip installs the package globally/system-wide. This pretty much defeats the purpose of your virtual environment which is to isolate a python environment for development and testing. Refer to official Python and the offending package documentation, if they do not install properly without sudo as it may mean you are missing a dependency or additional configurations in your virtual environment.

On a Debian 9.8 system (Linux 4.9.0-8-amd64), running the above steps and then running the following yielded me these results:

(env) user@host:~$ pip3 install flask
(env) user@host:~$ pip3 list --format=legacy
Click (7.0)
Flask (1.0.2)
itsdangerous (1.1.0)
Jinja2 (2.10)
MarkupSafe (1.1.1)
pip (9.0.1)
pkg-resources (0.0.0)
setuptools (32.3.1)
Wekzeug (0.15.1)
(env) user@host:~$ python3 --version
Python 3.5.3
  • Conceptually :) accurrate .. i am able to resolve many more issues using same concept..
    – Pavan Rao
    Oct 30, 2023 at 11:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .