Permissions warning with sudo pip install - python-2.7

I am using an ubuntu 14.04 64bit machine. The system python is 2.7.6.
This is what happens when I try to pip install anything
thekindlyone#deepthought:~$ sudo pip install pyopenssl
The directory '/home/thekindlyone/.cache/pip/log' or its parent directory is not owned by the current user and the debug log has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/thekindlyone/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/thekindlyone/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already satisfied (use --upgrade to upgrade): pyopenssl in /usr/lib/python2.7/dist-packages
pip is at 6.1.1
How do I get rid of these warnings?

Perhaps you want to use the sudo '-H' option to set the HOME environment variable to the home directory specified by the target user's password database entry.
That way, pip will use a cache directory in your root users home.
eg.
$ sudo -H pip install pyopenssl

Related

Could not install packages due to an EnvironmentError in ec2 server

i'm typing the following in my working amazon ec2 linux server. (with ENV activated)
pip install pillow
getting this error:
Could not install packages due to an EnvironmentError:
[Errno 13] Permission denied: '/home/ec2-user/env/lib64/python3.5/site-packages/Pillow-5.1.0.dist-info'.
Consider using the `--user` option or check the permissions.
if i use --user i get:
Can not perform a '--user' install. User site-packages are not visible in this virtualenv.
Based on your answers, what happened is that you used sudo when you created the virtualenv so root owns it.
sudo chown ec2-user:ec2-user -R ~ec2-user/env will fix this and make ec2-user the owner of the directory (and subdirectories) again.

Virtual Environment installation Error

When I try to install a virtual environment in my local system I'm getting this error. Could you please help me out to fix this issue?
$ pip -V
pip 9.0.1 from /home/sysadmin/.local/lib/python2.7/site-packages (python 2.7)
$ sudo pip install virutalenv
sudo: unable to resolve host sysadmin-Veriton-M200-H61
The directory '/home/sysadmin/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/sysadmin/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting virutalenv
Could not find a version that satisfies the requirement virutalenv (from versions: )
No matching distribution found for virutalenv
You have a typo there. It's virtualenv, not virutalenv.
Also, since you already have pip installed in .local, please don't install virtualenv using sudo.
Just
$ pip install --user virtualenv
should do, and virtualenv will be available in your user directory (~/.local/bin if memory serves, but find ~ -type f -name virtualenv will find it for you).

I already have python 2.7 install plus 3.6 install but when I try to install Django it give me the following error

The directory '/Users/sandeepkrishnan/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/sandeepkrishnan/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already satisfied: django in /Library/Python/2.7/site-packages
You're installing Django into Python 2.7 instead of 3.6, but you already have it installed in 2.7. To install it in Python 3.6, try pip3 install django and see if that works.

Cant install pip virtualenv virtualenvwrapper opencv3 python2.7 ubuntu

I'm new to Ubuntu and OpenCV. I'm trying to use this tutorial to get started. However, in steps 7 and 8 I can't install pip:
wget https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py
What should I do? I get this error:
The directory '/home/renzo/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/renzo/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
/tmp/tmpUEma37/pip.zip/pip/vendor/requests/packages/urllib3/util/ssl.py:315: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#snimissingwarning.
/tmp/tmpUEma37/pip.zip/pip/vendor/requests/packages/urllib3/util/ssl.py:120: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
Requirement already up-to-date: pip in /usr/local/lib/python2.7/dist-packages/pip-8.1.1-py2.7.egg
First thing to do is get ownership of that directory. In general, all files in your home directory (/home/renzo ) should be owned by the user (renzo in your case), but to address your problem specifically, take ownership of the .cache folder:
chown -R renzo /home/renzo/.cache
You may need to prefix it with sudo, i.e.:
sudo chown -R renzo /home/renzo/.cache
The -R makes it recursive, renzo is your username, and the hidden dotfile (actually folder) is .cache
Once you've done that, try the install command again.

How to install image processing just for a virtualenv project with pip for django

But I'm looking to install freetype, libjpeg, PIL build to add image processing to my django projects I've followed this installation http://dakrauth.com/blog/entry/python-and-django-setup-mac-os-x-leopard/ which installs it site wide but I can get it inside my virtualenv project.
Do I just cd into the working directory of the virtualenv (project) and install it there and will it just be available for that project or do I use pip? I couldn't find the packages in the pip repository. Can someone enlighten me please.
curl -O http://pypi.python.org/packages/source/d/distribute/distribute-0.6.21.tar.gz
tar -xzvf distribute-0.6.21.tar.gz
cd distribute-0.6.21
python distribute_setup.py
easy_install pip
pip install virtualenv
virtualenv --distribute --no-site-packages [myproject]
cd [myproject]
source bin/activate (this activates the sandbox that virtualenv created)
pip install django mysql-python
Go to the working directory of the virtualenv and then run
$ source bin/activate
This will set that virtual environment as your active one. So now that it's active, you can install what you want, either manually (by following those steps on the site you linked to) or with pip and it will automatically install it into your active virtualenv.
If you then, say, run python manage.py runserver while the same virtualenv is active, django will have access to your newly installed package. Once you want to unset that virtual environment as your active one, simply do deactivate.
I ran into something similar; what I did was install it into the default directory (e.g. Python27/Lib/site-packages) then cut and paste all the new files put there into the created environment's site-packages. Hacky, but works.
After that you can follow EEVIAC's instructions to actually get your server running.