Why I do not have permission to install psycopg2 in virtualenv

My goal is to show a Django welcome application in the world that uses postgres for an EC2 instance running under Ubuntu. I logged in via ssh and cloned the git repository containing the Django project with this requirement. Txt:

Django==1.8.2 djangorestframework==3.1.2 psycopg2==2.6 

I created virtualenv, and then when I ran (ec2_deploy_test) ubuntu@ip-172-31-22-100 :~/ec2-deploy-test$ pip install -r requirements.txt , this exception was thrown:

Collect psycopg2 == 2.6 (from -r requirements.txt (line 3)) / home / ubuntu / Envs / ec 2_deploy_test / local / lib / python2.7 / site-packages / pip / vendor / requests / packages / urllib3 / util /ssl.py:90: InsecurePlatformWarning: The true SSLContext is not available. This prevents urllib3 from properly configuring SSL and may cause some SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning . InsecurePlatformWarning Download psycopg2-2.6.tar.gz (367kB) 100% | โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ | 368kB 785kB / s Wheels for assembling assembled packages: psycopg2 Exception: Traceback (most recent last call): File "/home/ubuntu/Envs/ec2_deploy_test/local/lib/python2.7/site-packages/pip/basecommand.py" , line 223, basically status = self.run (options, args) File "/home/ubuntu/Envs/ec2_deploy_test/local/lib/python2.7/site-packages/pip/commands/install.py", line 291 , in perspective wb.build (autobuilding = True) File "/home/ubuntu/Envs/ec2_deploy_test/local/lib/python2.7/site-packages/pip/wheel.py", line 753, in the assembly make_dir (output_dir) File "/home/ubuntu/Envs/ec2_deploy_test/local/lib/python2.7/site-packages/pip/utils/ init .py", line 70, in the os.makedirs provisioning file (path) File "/ home / ubuntu / Envs / ec2_deploy_test / lib / python2.7 / os.py ", line 150, in makedirs makedirs (h ead, mode) File "/home/ubuntu/Envs/ec2_deploy_test/lib/python2.7/os.py", line 150, in makedirs makedirs (head, mode) File "/ home / ubuntu / Envs / ec2_deploy_test / lib / python2.7 / os.py ", line 150, in makedirs makedirs (head, mode) File" /home/ubuntu/Envs/ec2_deploy_test/lib/python2.7/os.py ", line 157, in makedirs mkdir (name , mode) OSError: [Errno 13] Permission denied: '/home/ubuntu/.cache/pip/wheels/ab'

Then I ran (ec2_deploy_test) ubuntu@ip-172-31-22-100 :~/ec2-deploy-test$ sudo pip install -r requirements.txt and psycopg2 successfully installed.

Why do I need root privileges to install the python package in my virtual environment? I am new to Linux and sysadmin in general, so all tips are welcome. Thanks in advance.

+6
source share
2 answers

For some reason, you do not have access to create a directory inside /home/ubuntu/.cache/pip/wheels/ab . Usually this problem should not appear; anyway, since this happened, just change the permissions of the .cache directory recursively. I think the problem is ownership, so try running the command sudo chown -R <USERNAME> ~/.cache/pip , where <USERNAME> should be your username.

Tip. Do not try to run applications from the root directory without the real need for this. Most likely, the directory to which you do not have access was created by some application running as root - and now the property is confused.

+6
source

I assume you used virtualenv -p / usr / bin / python3.4 env, I had the same problem

Its python 3 and may have nothing to do with permissions or root privileges if you have tried Angles recommendations and this will not work. You need to install python3-dev ... Or just stick with python2. hope that helps

heres link: Problem with psycopg2 in python3 virtualenv for use with Django

+1
source

Source: https://habr.com/ru/post/988205/


All Articles