0
votes

I am working on deploying my django application using uwsgi and nginx on a RHEL with pre installed python packages. Server is installed with uwsgi and nginx globally(as root). My server is not connected to internet.

I have secure copied my django project inside this server. For best practices I am told to use virtual environment and when I do the command,

virtualenv -p /usr/local/lib/python3.5/bin/python3.5 venv

All is cool. It creates a virtual environment with python 3.5.

But the problem is, I need these site packages which is pre installed on the server into this virtual environment. Example django, redis etc. When I do the above command with --system-site-packages it throws me this error

PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.6/site-packages/wheel-0.29.0.dist-info'

Is there a cleaner way to do this or where is it going wrong `?

2

2 Answers

1
votes

You may try:

$ pip freeze

where pip is the system-wide pip. If it outputs anything, then just do:

$ pip freeze > requirements.txt;
$ source /path/to/venv/bin/activate && pip install -r requirements.txt;

In this way you will tell the virtual environment's pip to install all the python packages that are installed system-wide.

If pip freeze doesn't work, this is a privilleges issue, you have to elaborate this as/with an admin.

UPD: You may need to install additional packages as python3-dev, build-essential etc for pip install -r requirements.txt to work.

0
votes

This might be happening because of the existence of another user in your machine.Just check if you have the system privileges , if not edit the properties of the file and grant it permission.