I'm trying to install the requests module on Mac following this tutorial http://docs.python-requests.org/en/master/user/install/
when I do the command pip install I get the following error:
Processing /Users/thomasmakkink/Documents/Acsone/Obfg/requests
Collecting chardet<3.1.0,>=3.0.2 (from requests==2.18.4)
Using cached chardet-3.0.4-py2.py3-none-any.whl
Collecting idna<2.7,>=2.5 (from requests==2.18.4)
Using cached idna-2.6-py2.py3-none-any.whl
Collecting urllib3<1.23,>=1.21.1 (from requests==2.18.4)
Using cached urllib3-1.22-py2.py3-none-any.whl
Collecting certifi>=2017.4.17 (from requests==2.18.4)
Using cached certifi-2018.1.18-py2.py3-none-any.whl
Installing collected packages: chardet, idna, urllib3, certifi, requests
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 784, in install
**kwargs
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/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-9.0.1-py2.7.egg/pip/req/req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/wheel.py", line 345, in move_wheel_files
clobber(source, lib_dir, True)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/wheel.py", line 316, in clobber
ensure_dir(destdir)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/utils/__init__.py", line 83, 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/chardet-3.0.4.dist-info'
How can I solve this?
sudo pip install requests
works well
Related
I am facing some errors and exceptions while installing requests module in python 3.6 version.
I am attaching screenshot of the errors that i am facing.click here for error screenshot
here is the error that i got on cmd windows
C:\Program Files (x86)\Python36-32\Scripts>pip3 install requests
Collecting requests
Using cached requests-2.18.4-py2.py3-none-any.whl
Collecting certifi>=2017.4.17 (from requests)
Using cached certifi-2017.7.27.1-py2.py3-none-any.whl
Collecting urllib3<1.23,>=1.21.1 (from requests)
Using cached urllib3-1.22-py2.py3-none-any.whl
Collecting idna<2.7,>=2.5 (from requests)
Using cached idna-2.6-py2.py3-none-any.whl
Collecting chardet<3.1.0,>=3.0.2 (from requests)
Using cached chardet-3.0.4-py2.py3-none-any.whl
Installing collected packages: certifi, urllib3, idna, chardet, requests
Exception:
Traceback (most recent call last):
File "c:\program files (x86)\python36-32\lib\site-packages\pip\basecommand.py"
, line 215, in main
status = self.run(options, args)
File "c:\program files (x86)\python36-32\lib\site-packages\pip\commands\instal
l.py", line 342, in run
prefix=options.prefix_path,
File "c:\program files (x86)\python36-32\lib\site-packages\pip\req\req_set.py"
, line 784, in install
**kwargs
File "c:\program files (x86)\python36-32\lib\site-packages\pip\req\req_install
.py", line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "c:\program files (x86)\python36-32\lib\site-packages\pip\req\req_install
.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "c:\program files (x86)\python36-32\lib\site-packages\pip\wheel.py", line
345, in move_wheel_files
clobber(source, lib_dir, True)
File "c:\program files (x86)\python36-32\lib\site-packages\pip\wheel.py", line
316, in clobber
ensure_dir(destdir)
File "c:\program files (x86)\python36-32\lib\site-packages\pip\utils\__init__.
py", line 83, in ensure_dir
os.makedirs(path)
File "c:\program files (x86)\python36-32\lib\os.py", line 220, in makedirs
mkdir(name, mode)
PermissionError: [WinError 5] Access is denied: 'c:\\program files (x86)\\python
36-32\\Lib\\site-packages\\certifi'
Thanks in advance
The issue that you are facing is because of a permission error. This is likely because you have not run the command line prompt as an administrator. So, the best thing to do is right click on the command line icon, and run as administrator. Once you've done that, continue normally and install requests using pip install requests. Normally, when you try to install python packages in the main python installation, this error occurs, because you need admin privileges in order to write to anything in Program Files.
That should solve the problem. However, what would be a better option would be to install the virtualenv package, and then have localized installation of packages, so that you can avoid these messy installations that require special rights.
I just reinstalled Python 3.6, but when I try to install packages, Windows returns errors. First I tried installing package BeautifulSoup from the Windows command prompt:
python -m pip install BeautifulSoup
but this returns the following error:
Collecting BeautifulSoup
Using cached BeautifulSoup-3.2.1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\Robert\AppData\Local\Temp\pip-build-iiyyxs2o\BeautifulSoup\setup.py", line 22
print "Unit tests have failed!"
^
SyntaxError: Missing parentheses in call to 'print'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\Robert\AppData\Local\Temp\pip-build-iiyyxs2o\BeautifulSoup\
Then I tried installing package requests:
python -m pip install requests
but this returns
C:\Program Files\Python36>python -m pip install requests
Collecting requests
Using cached requests-2.18.4-py2.py3-none-any.whl
Collecting certifi>=2017.4.17 (from requests)
Using cached certifi-2017.7.27.1-py2.py3-none-any.whl
Collecting idna<2.7,>=2.5 (from requests)
Using cached idna-2.6-py2.py3-none-any.whl
Collecting chardet<3.1.0,>=3.0.2 (from requests)
Using cached chardet-3.0.4-py2.py3-none-any.whl
Collecting urllib3<1.23,>=1.21.1 (from requests)
Using cached urllib3-1.22-py2.py3-none-any.whl
Installing collected packages: certifi, idna, chardet, urllib3, requests
Exception:
Traceback (most recent call last):
File "C:\Program Files\Python36\lib\site-packages\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "C:\Program Files\Python36\lib\site-packages\pip\commands\install.py", line 342, in run
prefix=options.prefix_path,
File "C:\Program Files\Python36\lib\site-packages\pip\req\req_set.py", line 784, in install
**kwargs
File "C:\Program Files\Python36\lib\site-packages\pip\req\req_install.py", line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "C:\Program Files\Python36\lib\site-packages\pip\req\req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "C:\Program Files\Python36\lib\site-packages\pip\wheel.py", line 345, in move_wheel_files
clobber(source, lib_dir, True)
File "C:\Program Files\Python36\lib\site-packages\pip\wheel.py", line 316, in clobber
ensure_dir(destdir)
File "C:\Program Files\Python36\lib\site-packages\pip\utils\__init__.py", line 83, in ensure_dir
os.makedirs(path)
File "C:\Program Files\Python36\lib\os.py", line 220, in makedirs
mkdir(name, mode)
PermissionError: [WinError 5] Access is denied: 'C:\\Program Files\\Python36\\Lib\\site-packages\\certifi'
What do I need to do so that pip successfully installs packages?
BeautifulSoup is for Python 2 only. For Python 3 install beautifulsoup4:
pip install beautifulsoup4
The second problem seems obvious: you don't have write-access to C:\\Program Files\\Python36\\Lib\\site-packages and subdirectories.
I can't install packages in PyCharm
throws this error
Collecting oktaauth
Downloading oktaauth-0.2-py2-none-any.whl
Requirement already satisfied: requests>=2.8 in /Library/Python/2.7/site-packages (from oktaauth)
Collecting argparse (from oktaauth)
Downloading argparse-1.4.0-py2.py3-none-any.whl
Collecting beautifulsoup4>=4.4 (from oktaauth)
Downloading beautifulsoup4-4.6.0-py2-none-any.whl (86kB)
Installing collected packages: argparse, beautifulsoup4, oktaauth
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 784, in install
**kwargs
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/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-9.0.1-py2.7.egg/pip/req/req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/wheel.py", line 247, in move_wheel_files
prefix=prefix,
File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/locations.py", line 153, in distutils_scheme
i.finalize_options()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/install.py", line 346, in finalize_options
self.create_home_path()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/install.py", line 565, in create_home_path
os.makedirs(path, 0700)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 150, in makedirs
makedirs(head, mode)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 150, in makedirs
makedirs(head, mode)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 150, in makedirs
makedirs(head, mode)
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: '/Users/karanj/Library/Python/2.7'
I found soltutions by asking me to try installing it by being root or trying sudo with the command and try installing the package. But I don't want to install the package by appending sudo to it.
Any solutions?
When you start a python project, always use Python virtual environemnt. Avoid using use sudo pip install.
You can either
create Pycharm virtual environment, or
Create your typical virtualenv, then add external virtualenv to Pycharm, or
Use pycharm with conda, another virtual environment.
Try with sudo
If there is a requirement file e.g. sudo pip install -r requirements.txt
Or for standalone package
sudo pip install <package-name>
I'm trying to install pip using this command:
python get-pip.py
The error it's spitting out is this - can you help? (I'm running macOS 10.12.1)
Collecting pip
Using cached pip-8.1.2-py2.py3-none-any.whl
Collecting wheel
Using cached wheel-0.29.0-py2.py3-none-any.whl
Installing collected packages: pip, wheel
Exception:
Traceback (most recent call last):
File "/var/folders/by/db2rdr7n1753qbfz0rlgk7hw0000gn/T/tmptA1AVr/pip.zip/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/var/folders/by/db2rdr7n1753qbfz0rlgk7hw0000gn/T/tmptA1AVr/pip.zip/pip/commands/install.py", line 317, in run
prefix=options.prefix_path,
File "/var/folders/by/db2rdr7n1753qbfz0rlgk7hw0000gn/T/tmptA1AVr/pip.zip/pip/req/req_set.py", line 742, in install
**kwargs
File "/var/folders/by/db2rdr7n1753qbfz0rlgk7hw0000gn/T/tmptA1AVr/pip.zip/pip/req/req_install.py", line 831, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/var/folders/by/db2rdr7n1753qbfz0rlgk7hw0000gn/T/tmptA1AVr/pip.zip/pip/req/req_install.py", line 1032, in move_wheel_files
isolated=self.isolated,
File "/var/folders/by/db2rdr7n1753qbfz0rlgk7hw0000gn/T/tmptA1AVr/pip.zip/pip/wheel.py", line 346, in move_wheel_files
clobber(source, lib_dir, True)
File "/var/folders/by/db2rdr7n1753qbfz0rlgk7hw0000gn/T/tmptA1AVr/pip.zip/pip/wheel.py", line 317, in clobber
ensure_dir(destdir)
File "/var/folders/by/db2rdr7n1753qbfz0rlgk7hw0000gn/T/tmptA1AVr/pip.zip/pip/utils/init.py", line 83, 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/pip'
To install pip you on Mac OSX you can try :
sudo easy_install pip
The "sudo" keyword is what will grant you root privileges.
You need root access. Activate your root account and try from there.
I'm getting some exceptions while trying to install praw using pip. Following is the error messages I get:
MacBook:usr name_r$ pip install praw
Downloading/unpacking praw
Downloading praw-2.1.20-py2.py3-none-any.whl (74kB): 74kB downloaded
Downloading/unpacking requests>=2.3.0 (from praw)
Downloading requests-2.5.1-py2.py3-none-any.whl (464kB): 464kB downloaded
Downloading/unpacking update-checker>=0.11 (from praw)
Downloading update_checker-0.11-py2.py3-none-any.whl
Requirement already satisfied (use --upgrade to upgrade): six>=1.4 in /Library/Python/2.7/site-packages/six-1.8.0-py2.7.egg (from praw)
Installing collected packages: praw, requests, update-checker
Cleaning up...
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-1.5.6-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.6-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.6-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.6-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.6-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.6-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.6-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 /var/folders/qz/q26gj5zx62d3d206hdnn_rwm0000gn/T/tmp_wCuvN
Could someone tell me whats going on here? Do I need to update Python somehow or is something wrong with pip?
How can I get it to install praw properly?
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'
It seems you are running on Mac, you need to change to the root user for installation, otherwise you don't have the write privilege for the folder. "sudo -s" will change to root.