I am a student and I am doing project on department computer, system Linux 7.2. Now I am trying to install pip so that I can install python packages using it.
I have downloaded get-pip.py and tried to install via python get-pip.py. It gives me:
Collecting pip
Downloading pip-8.1.1-py2.py3-none-any.whl (1.2MB)
100% |████████████████████████████████| 1.2MB 471kB/s
Collecting wheel
Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
100% |████████████████████████████████| 71kB 764kB/s
Installing collected packages: pip, wheel
Exception:
Traceback (most recent call last):
File "/tmp/tmpqybTwL/pip.zip/pip/basecommand.py", line 209, in main
status = self.run(options, args)
File "/tmp/tmpqybTwL/pip.zip/pip/commands/install.py", line 317, in run
prefix=options.prefix_path,
File "/tmp/tmpqybTwL/pip.zip/pip/req/req_set.py", line 732, in install
**kwargs
File "/tmp/tmpqybTwL/pip.zip/pip/req/req_install.py", line 835, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/tmp/tmpqybTwL/pip.zip/pip/req/req_install.py", line 1030, in move_wheel_files
isolated=self.isolated,
File "/tmp/tmpqybTwL/pip.zip/pip/wheel.py", line 344, in move_wheel_files
clobber(source, lib_dir, True)
File "/tmp/tmpqybTwL/pip.zip/pip/wheel.py", line 315, in clobber
ensure_dir(destdir)
File "/tmp/tmpqybTwL/pip.zip/pip/utils/__init__.py", line 83, in ensure_dir
os.makedirs(path)
File "/usr/lib64/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/usr/lib/python2.7/site-packages/pip'
Then, I tried to install using sudo python get-pip.py, however, I got "xxx is not in the sudoers file. This incident will be reported."
So, I was wondering whether I don't have the permission to root and don't have the right to do sudo...but I am not sure about this...
Any suggestion to fix this problem? And in the end, I want to install scipy and gensim.
Does the system hand you a virtualenv command?
Then you should read about virtualenvs. Comes in handy anyhow.
If not you may use the approach by Jasper van den Bosch
You either need to use a virtual environement, and install the pip package in the virtual env. Or install it with pip globally ie system wide as root user
Try install pip using easy_install
Try Below commands in terminal:
sudo su
easy_install pip
Related
I tried to install the mysql connector for my python environment.
I use python on my Linux (Ubuntu 16.04) machine.
On this machine python 2.7.12 and python 3.5.2.
I probably messed something up because of my inexperience with installing new python modules.
When I now try to install the mysql connector with the command
pip3 install mysql-connector-python-rf
I get the following messages:
Collecting mysql-connector-python-rf Downloading
mysql-connector-python-rf-2.2.2.tar.gz (11.9MB)
100% |████████████████████████████████| 11.9MB 131kB/s Building wheels for collected packages: mysql-connector-python-rf Running
setup.py bdist_wheel for mysql-connector-python-rf ... done Stored
in directory:
/home/claude/.cache/pip/wheels/bb/53/e4/dced82f8a15f96a8afbe626ebb2939d2901b29e610a97fc1ba
Successfully built mysql-connector-python-rf Installing collected
packages: mysql-connector-python-rf Exception: Traceback (most recent
call last): File
"/home/claude/.local/lib/python3.5/site-packages/pip/basecommand.py",
line 215, in main
status = self.run(options, args) File "/home/claude/.local/lib/python3.5/site-packages/pip/commands/install.py",
line 342, in run
prefix=options.prefix_path, File "/home/claude/.local/lib/python3.5/site-packages/pip/req/req_set.py",
line 784, in install
**kwargs File "/home/claude/.local/lib/python3.5/site-packages/pip/req/req_install.py",
line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix) File
"/home/claude/.local/lib/python3.5/site-packages/pip/req/req_install.py",
line 1064, in move_wheel_files
isolated=self.isolated, File "/home/claude/.local/lib/python3.5/site-packages/pip/wheel.py", line
345, in move_wheel_files
clobber(source, lib_dir, True) File "/home/claude/.local/lib/python3.5/site-packages/pip/wheel.py", line
316, in clobber
ensure_dir(destdir) File "/home/claude/.local/lib/python3.5/site-packages/pip/utils/init.py",
line 83, in ensure_dir
os.makedirs(path) File "/usr/lib/python3.5/os.py", line 241, in makedirs
mkdir(name, mode) PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.5/dist-packages/mysql_connector_python_rf-2.2.2.dist-info'
How can a correct this problem?
Or How can I do a correct fresh install of my python2 and python3 environment on my Ubuntu 16.04 x86 Linux?
There is nothing wrong with your installation. To install packages globally, you need superuser privileges; you would run that command under sudo.
However, you should avoid doing this. Create a virtualenv and install the package there.
I tried to install the python library openpyxl using pip by typing into the terminal:
pip install openpyxl
But it was not executed properly. It threw an exception:
Successfully built openpyxl jdcal et-xmlfile
Installing collected packages: jdcal, et-xmlfile, openpyxl
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 784, in install
**kwargs
File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "/Library/Python/2.7/site-packages/pip/wheel.py", line 345, in move_wheel_files
clobber(source, lib_dir, True)
File "/Library/Python/2.7/site-packages/pip/wheel.py", line 323, in clobber
shutil.copyfile(srcfile, destfile)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 83, in copyfile
with open(dst, 'wb') as fdst:
IOError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/jdcal.py'
Best way is probably to use pip install <libname> --user
Meaning in your case use pip install openpyxel --user
This installs the package for your user and that is safe. Also you have probably the right of installing the package for the user.
The permission error you have encountered is a frequent problem. As can be seen here:
pip is not able to install packages correctly: Permission denied error
and here error: could not create '/usr/local/lib/python2.7/dist-packages/virtualenv_support': Permission denied
Using the sudo pip command is not considered as safe as explained here: What are the risks of running 'sudo pip'?
Your user doesn't have write permissions in the Python installation folder.
To fix it, run pip as root:
sudo pip install openpyxl
Your account does not have write access to this directory?.
If the installation directory is a system-owned directory, you may
need to sign in as the administrator or "root" account.
sudo pip install openpyxl
If you do not have administrative access to this machine, you may
wish to choose a different installation directory, preferably one
that is listed in your PYTHON_PATH environment variable.
easier way: change that dir permission:
chmod +a 'user:YOUR_USER_NAME allow add_subdirectory,add_file,delete_child,directory_inherit' /Library/Python/2.7/site-packages
Change security setting of site-packages folder to "Full Control" for your user and re run pip install openpyxl
I'm trying to install django using pip in Terminal.
I always get an exception, however. The last error is always "permission denied", and I do not understand why. Any help is appreciated.
Log:
pip install django
You are using pip version 7.1.0, however version 8.1.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting django
Using cached Django-1.9.4-py2.py3-none-any.whl
Installing collected packages: django
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/basecommand.py", line 223, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/commands/install.py", line 299, in run
root=options.root_path,
File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/req/req_set.py", line 646, in install
**kwargs
File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/req/req_install.py", line 813, in install
self.move_wheel_files(self.source_dir, root=root)
File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/req/req_install.py", line 1008, in move_wheel_files
isolated=self.isolated,
File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/wheel.py", line 339, in move_wheel_files
clobber(source, lib_dir, True)
File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/wheel.py", line 310, in clobber
ensure_dir(destdir)
File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/utils/__init__.py", line 70, in ensure_dir
os.makedirs(path)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/django'
sudo pip install django
The error tells you that you can't access a directory (you don't have enough permissions), so you can gain root access via sudo to get the permissions.
pip should be run by a user which has permissions to write to site-packages directory (in your case, /Library/Python/2.7/site-packages/). You should either run it from the root user or under sudo.
My Solution for [Errno 13] Permission denied:
Target: To install package into system/virtualenv
Why you get this problem?
Because apart from root, other users you created don't have permission to write to site-packages, that is why you get OS error permission denied for that user
How to solve?
Make sure you activated the virtualenv all the time
Source bin/activate
Suppose, I created a user
(sampleEnv) sunny#ubuntu-512mb-lon1-01: pip install django
This will give the Permission error, Instead of that shift to root
$ su -
(sampleEnv) root#ubuntu-512mb-lon1-01: pip install django
Now root have permission to write to site-packages.
Once django is installed. Shift back to user
$ su - sunny
then do pip freeze you can see packages installed in system and go on!
I have been trying to set up virtualenv for use with django, but I keep having issues installing virtualenv with pip.
jeff#jeff-HP-MacBook-Android:~/repos$ pip install virtualenv
Collecting virtualenv
Using cached virtualenv-13.1.2-py2.py3-none-any.whl
Installing collected packages: virtualenv
Exception:
Traceback (most recent call last):
File "/home/jeff/.local/lib/python2.7/site-packages/pip/basecommand.py", line 211, in main
status = self.run(options, args)
File "/home/jeff/.local/lib/python2.7/site-packages/pip/commands/install.py", line 311, in run
root=options.root_path,
File "/home/jeff/.local/lib/python2.7/site-packages/pip/req/req_set.py", line 646, in install
**kwargs
File "/home/jeff/.local/lib/python2.7/site-packages/pip/req/req_install.py", line 803, in install
self.move_wheel_files(self.source_dir, root=root)
File "/home/jeff/.local/lib/python2.7/site-packages/pip/req/req_install.py", line 998, in move_wheel_files
isolated=self.isolated,
File "/home/jeff/.local/lib/python2.7/site-packages/pip/wheel.py", line 339, in move_wheel_files
clobber(source, lib_dir, True)
File "/home/jeff/.local/lib/python2.7/site-packages/pip/wheel.py", line 317, in clobber
shutil.copyfile(srcfile, destfile)
File "/usr/lib/python2.7/shutil.py", line 83, in copyfile
with open(dst, 'wb') as fdst:
IOError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/virtualenv.py'
jeff#jeff-HP-MacBook-Android:~/repos$
The closest answer I can find regards permissions inside the virtualenv: How to avoid "Permission denied" when using pip with virtualenv
But from what I can tell my issue is that there's something wrong with my install of pip, since I apparently don't even have virtualenv yet.
I don't think there's anything wrong with your pip installation. virtualenv is itself a Python module, and by default it goes in /usr/local/lib/python2.7/dist-packages, a folder for which your user does not have write permissions. If you have sudo access, it would be easiest to simply try:
sudo pip install virtualenv
Once you've done that, you should be able to create virtualenvs without needing to use sudo. Alternately, there are instructions here for making your own virtual environment, but it looks like you will likely need to do some manual editing of the script it directs you to download.
I have already installed homebrew and pip. When I run $pip install praw the following comes up:
dhcp-215-185:~ my_name$ pip install praw
Downloading/unpacking praw
Downloading praw-2.1.16-py2.py3-none-any.whl (70kB): 70kB downloaded
Downloading/unpacking update-checker>=0.10 (from praw)
Downloading update_checker-0.10-py2.py3-none-any.whl
Downloading/unpacking requests>=1.2.0 (from praw)
Downloading requests-2.2.1-py2.py3-none-any.whl (625kB): 625kB downloaded
Downloading/unpacking six>=1.4 (from praw)
Downloading six-1.6.1-py2.py3-none-any.whl
Installing collected packages: praw, update-checker, requests, six
Cleaning up...
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-1.5.5-py2.7.egg/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-1.5.5-py2.7.egg/pip/commands/install.py", line 283, in run
requirement_set.install(install_options, global_options, root=options.root_path)
File "/Library/Python/2.7/site-packages/pip-1.5.5-py2.7.egg/pip/req.py", line 1435, in install
requirement.install(install_options, global_options, *args, **kwargs)
File "/Library/Python/2.7/site-packages/pip-1.5.5-py2.7.egg/pip/req.py", line 671, in install
self.move_wheel_files(self.source_dir, root=root)
File "/Library/Python/2.7/site-packages/pip-1.5.5-py2.7.egg/pip/req.py", line 901, in move_wheel_files
pycompile=self.pycompile,
File "/Library/Python/2.7/site-packages/pip-1.5.5-py2.7.egg/pip/wheel.py", line 215, in move_wheel_files
clobber(source, lib_dir, True)
File "/Library/Python/2.7/site-packages/pip-1.5.5-py2.7.egg/pip/wheel.py", line 205, in clobber
os.makedirs(destdir)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/praw'
Storing debug log for failure in /Users/my_name/Library/Logs/pip.log
dhcp-215-185:~ my_name$
Does anyone have a fix? Installing this has been a real headache. Thanks a lot!
A quick workaround would be to use the sudo pip install praw command to intall praw as a super-user. However, this is not recommended, as it can cause problems later on with things such as updates and scaling your application upwards. One would instead suggest that you create a virtual environment, and pip install praw inside it.
If you are confident that the application you are building will not grow too large, it is probably ok to install praw using sudo.
I was getting the same error as you and I found an answer in the reddit documentation for PRAW. I used HomeBrew to install pip and I'm using Python 3.x instead of the 2.7x that's shipped with OSX, which means I needed to use pip3 instead of pip. It worked right away.
I hope this helps!