setuptools pip wheel failed with error code 2 - python

I am going through the Google Cloud Platform's Python Bookshelf App Tutorial and I am at the step of starting up my virtualenv where I am stuck.
Running virtualenv -p python3 env produces this error:
⇒ virtualenv -p python3 env
Running virtualenv with interpreter /Library/Frameworks/Python.framework/Versions/3.6/bin/python3
Using base prefix '/Library/Frameworks/Python.framework/Versions/3.6'
New python executable in /Users/puoygae/Lab/gae-bookshelf-app-python-flexible-experiment/getting-started-python/2-structured-data/env/bin/python3
Also creating executable in /Users/puoygae/Lab/gae-bookshelf-app-python-flexible-experiment/getting-started-python/2-structured-data/env/bin/python
Please make sure you remove any previous custom paths from your /Users/puoygae/.pydistutils.cfg file.
Installing setuptools, pip, wheel...
Complete output from command /Users/puoygae/Lab/ga...data/env/bin/python3 - setuptools pip wheel:
Collecting setuptools
Using cached https://files.pythonhosted.org/packages/75/b3/0a106dfaf7f48aef638da80b32608617cc8de4b24a22c8cd3759c32e5d30/setuptools-41.1.0-py2.py3-none-any.whl
Collecting pip
Using cached https://files.pythonhosted.org/packages/8d/07/f7d7ced2f97ca3098c16565efbe6b15fafcba53e8d9bdb431e09140514b0/pip-19.2.2-py2.py3-none-any.whl
Collecting wheel
Using cached https://files.pythonhosted.org/packages/bb/10/44230dd6bf3563b8f227dbf344c908d412ad2ff48066476672f3a72e174e/wheel-0.33.4-py2.py3-none-any.whl
Installing collected packages: setuptools, pip, wheel
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/virtualenv_support/pip-8.0.2-py2.py3-none-any.whl/pip/basecommand.py", line 209, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/virtualenv_support/pip-8.0.2-py2.py3-none-any.whl/pip/commands/install.py", line 317, in run
prefix=options.prefix_path,
File "/Library/Python/2.7/site-packages/virtualenv_support/pip-8.0.2-py2.py3-none-any.whl/pip/req/req_set.py", line 731, in install
**kwargs
File "/Library/Python/2.7/site-packages/virtualenv_support/pip-8.0.2-py2.py3-none-any.whl/pip/req/req_install.py", line 841, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/Library/Python/2.7/site-packages/virtualenv_support/pip-8.0.2-py2.py3-none-any.whl/pip/req/req_install.py", line 1040, in move_wheel_files
isolated=self.isolated,
File "/Library/Python/2.7/site-packages/virtualenv_support/pip-8.0.2-py2.py3-none-any.whl/pip/wheel.py", line 343, in move_wheel_files
clobber(source, lib_dir, True)
File "/Library/Python/2.7/site-packages/virtualenv_support/pip-8.0.2-py2.py3-none-any.whl/pip/wheel.py", line 321, in clobber
shutil.copyfile(srcfile, destfile)
File "/Users/puoygae/Lab/gae-bookshelf-app-python-flexible-experiment/getting-started-python/2-structured-data/env/lib/python3.6/shutil.py", line 121, in copyfile
with open(dst, 'wb') as fdst:
PermissionError: [Errno 13] Permission denied: '/lib/python3.6/site-packages/easy_install.py'
----------------------------------------
...Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/virtualenv.py", line 2327, in <module>
main()
File "/Library/Python/2.7/site-packages/virtualenv.py", line 711, in main
symlink=options.symlink)
File "/Library/Python/2.7/site-packages/virtualenv.py", line 944, in create_environment
download=download,
File "/Library/Python/2.7/site-packages/virtualenv.py", line 900, in install_wheel
call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT)
File "/Library/Python/2.7/site-packages/virtualenv.py", line 795, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /Users/puoygae/Lab/ga...data/env/bin/python3 - setuptools pip wheel failed with error code 2
I had followed this guide to set up my python development environment. I searched the internet for a solution but I haven't had luck getting pass this step.
What is causing the issue and how can I fix it?
EDIT: Running it with sudo produces the following error:
⇒ sudo virtualenv -p python3 env
Password:
Running virtualenv with interpreter /Library/Frameworks/Python.framework/Versions/3.6/bin/python3
Using base prefix '/Library/Frameworks/Python.framework/Versions/3.6'
New python executable in /Users/myUserName/Lab/gae-bookshelf-app-python-flexible-experiment/getting-started-python/2-structured-data/env/bin/python3
Not overwriting existing python script /Users/myUserName/Lab/gae-bookshelf-app-python-flexible-experiment/getting-started-python/2-structured-data/env/bin/python (you must use /Users/myUserName/Lab/gae-bookshelf-app-python-flexible-experiment/getting-started-python/2-structured-data/env/bin/python3)
Please make sure you remove any previous custom paths from your /Users/myUserName/.pydistutils.cfg file.
Installing setuptools, pip, wheel...
Complete output from command /Users/myUserName/Lab/ga...data/env/bin/python3 - setuptools pip wheel:
The directory '/Users/myUserName/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/myUserName/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.
Collecting setuptools
Downloading https://files.pythonhosted.org/packages/75/b3/0a106dfaf7f48aef638da80b32608617cc8de4b24a22c8cd3759c32e5d30/setuptools-41.1.0-py2.py3-none-any.whl (576kB)
Collecting pip
Downloading https://files.pythonhosted.org/packages/8d/07/f7d7ced2f97ca3098c16565efbe6b15fafcba53e8d9bdb431e09140514b0/pip-19.2.2-py2.py3-none-any.whl (1.4MB)
Collecting wheel
Downloading https://files.pythonhosted.org/packages/bb/10/44230dd6bf3563b8f227dbf344c908d412ad2ff48066476672f3a72e174e/wheel-0.33.4-py2.py3-none-any.whl
Installing collected packages: setuptools, pip, wheel
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/virtualenv_support/pip-8.0.2-py2.py3-none-any.whl/pip/basecommand.py", line 209, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/virtualenv_support/pip-8.0.2-py2.py3-none-any.whl/pip/commands/install.py", line 317, in run
prefix=options.prefix_path,
File "/Library/Python/2.7/site-packages/virtualenv_support/pip-8.0.2-py2.py3-none-any.whl/pip/req/req_set.py", line 731, in install
**kwargs
File "/Library/Python/2.7/site-packages/virtualenv_support/pip-8.0.2-py2.py3-none-any.whl/pip/req/req_install.py", line 841, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/Library/Python/2.7/site-packages/virtualenv_support/pip-8.0.2-py2.py3-none-any.whl/pip/req/req_install.py", line 1040, in move_wheel_files
isolated=self.isolated,
File "/Library/Python/2.7/site-packages/virtualenv_support/pip-8.0.2-py2.py3-none-any.whl/pip/wheel.py", line 476, in move_wheel_files
generated.extend(maker.make(spec))
File "/Library/Python/2.7/site-packages/virtualenv_support/pip-8.0.2-py2.py3-none-any.whl/pip/_vendor/distlib/scripts.py", line 353, in make
self._make_script(entry, filenames, options=options)
File "/Library/Python/2.7/site-packages/virtualenv_support/pip-8.0.2-py2.py3-none-any.whl/pip/_vendor/distlib/scripts.py", line 257, in _make_script
self._write_script(scriptnames, shebang, script, filenames, ext)
File "/Library/Python/2.7/site-packages/virtualenv_support/pip-8.0.2-py2.py3-none-any.whl/pip/_vendor/distlib/scripts.py", line 231, in _write_script
self._fileop.write_binary_file(outname, script_bytes)
File "/Library/Python/2.7/site-packages/virtualenv_support/pip-8.0.2-py2.py3-none-any.whl/pip/_vendor/distlib/util.py", line 388, in write_binary_file
with open(path, 'wb') as f:
PermissionError: [Errno 1] Operation not permitted: '/bin/easy_install'
----------------------------------------
...Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/virtualenv.py", line 2327, in <module>
main()
File "/Library/Python/2.7/site-packages/virtualenv.py", line 711, in main
symlink=options.symlink)
File "/Library/Python/2.7/site-packages/virtualenv.py", line 944, in create_environment
download=download,
File "/Library/Python/2.7/site-packages/virtualenv.py", line 900, in install_wheel
call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT)
File "/Library/Python/2.7/site-packages/virtualenv.py", line 795, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /Users/myUserName/Lab/ga...data/env/bin/python3 - setuptools pip wheel failed with error code 2

#puoygae fixed his issue by creating a new User account on his MacOS and installed python separately. The environment in his Admin account was convoluted.
Other fixes to this known issue can be :
Removing all virtualenv* things in
/usr/local/lib/python2.7/dist-packages/ and reinstalling it as per
this GitHub issue.
Uninstall any setuptools and wheels from pip. Also uninstall them
from the apt-get remove wheel setuptools virutalenv(if they exist,
In some cases wheels and setuptools both can exist and may conflict
with each other from pip and apt-get installations) > Download fresh
setuptools-35.0.2 from here and virutalenv-15.1.0 from here.
Install both the tools freshly.
Follow the instructions on updating openSSL here and then try
setting up a virtual environment using pip install.
Could try to open the system terminal and type pip install
virtualenv. Restart IDE.
Try installing pysocks - sudo pip install pysocks Use - unset
all_proxy Retry
Also you can try upgrading to platformio-ide 2.1.5
"setenv all_proxy https://proxy_here:port_here/". Solves the proxy
problem for not only this setup but for all installations.
Also have a look at this stackoverflow thread fixes for the
same issue.
Reference Links :
https://github.com/platformio/platformio-atom-ide/issues/1245
https://github.com/pypa/virtualenv/issues/876

I had this problem as well.
My pip was looking at a different repo, the one I created using AWS's CodeArtifact, which needs login and credentials.
In my case, all I needed to do was erase this file ~/.config/pip/pip.config

Related

Can't install cryptography on raspberry pi because of libffi [duplicate]

This question already has answers here:
pip install failing with: OSError: [Errno 13] Permission denied on directory
(9 answers)
Closed 4 years ago.
I've been trying to install the package "flask-ask" on my Raspberry Pi Zero. However, there's a problem when trying to install the dependency "cryptography":
Downloading/unpacking cryptography
Downloading cryptography-2.2.2.tar.gz (443kB): 443kB downloaded
Running setup.py (path:/tmp/pip-build-wg353po4/cryptography/setup.py) egg_info for package cryptography
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/tmp/pip-build-wg353po4/cryptography/setup.py", line 28, in <module>
"cryptography requires setuptools 18.5 or newer, please upgrade to a "
RuntimeError: cryptography requires setuptools 18.5 or newer, please upgrade to a newer version of setuptools
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/tmp/pip-build-wg353po4/cryptography/setup.py", line 28, in <module>
"cryptography requires setuptools 18.5 or newer, please upgrade to a "
RuntimeError: cryptography requires setuptools 18.5 or newer, please upgrade to a newer version of setuptools
----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip-build-wg353po4/cryptography
Storing debug log for failure in /home/pi/.pip/pip.log
(these logs gotten from trying to install cryptography on its own, but the same error is gotten when installing flask-ask)
I've tried pip3 install -U setuptools to upgrade it, but that doesn't work:
pi#raspberrypi:~ $ pip3 install -U setuptools
Downloading/unpacking setuptools from https://files.pythonhosted.org/packages/7f/e1/820d941153923aac1d49d7fc37e17b6e73bfbd2904959fffbad77900cf92/setuptools-39.2.0-py2.py3-none-any.whl#sha256=8fca9275c89964f13da985c3656cb00ba029d7f3916b37990927ffdf264e7926
Downloading setuptools-39.2.0-py2.py3-none-any.whl (567kB): 567kB downloaded
Installing collected packages: setuptools
Found existing installation: setuptools 5.5.1
Not uninstalling setuptools at /usr/lib/python3/dist-packages, owned by OS
Can't roll back setuptools; was not uninstalled
Cleaning up...
Exception:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 295, in run
requirement_set.install(install_options, global_options, root=options.root_path)
File "/usr/lib/python3/dist-packages/pip/req.py", line 1436, in install
requirement.install(install_options, global_options, *args, **kwargs)
File "/usr/lib/python3/dist-packages/pip/req.py", line 672, in install
self.move_wheel_files(self.source_dir, root=root)
File "/usr/lib/python3/dist-packages/pip/req.py", line 902, in move_wheel_files
pycompile=self.pycompile,
File "/usr/lib/python3/dist-packages/pip/wheel.py", line 214, in move_wheel_files
clobber(source, lib_dir, True)
File "/usr/lib/python3/dist-packages/pip/wheel.py", line 208, in clobber
shutil.copy2(srcfile, destfile)
File "/usr/lib/python3.4/shutil.py", line 244, in copy2
copyfile(src, dst, follow_symlinks=follow_symlinks)
File "/usr/lib/python3.4/shutil.py", line 108, in copyfile
with open(dst, 'wb') as fdst:
PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.4/dist-packages/easy_install.py'
Storing debug log for failure in /home/pi/.pip/pip.log
So what should I do? I've done a lot of googling of various different things, and I've seen other people have problems with cryptography on the Pi, but not this specific problem.
EDIT: Ok, so I've done pip install --user -U setuptools now, and that works fine. Now I'm getting a totally different error:
running install_egg_info
running egg_info
creating lib/PyYAML.egg-info
writing lib/PyYAML.egg-info/PKG-INFO
writing top-level names to lib/PyYAML.egg-info/top_level.txt
writing dependency_links to lib/PyYAML.egg-info/dependency_links.txt
writing manifest file 'lib/PyYAML.egg-info/SOURCES.txt'
reading manifest file 'lib/PyYAML.egg-info/SOURCES.txt'
writing manifest file 'lib/PyYAML.egg-info/SOURCES.txt'
Copying lib/PyYAML.egg-info to /home/pi/.local/lib/python2.7/site-packages/PyYAML-3.12$
running install_scripts
writing list of installed files to '/tmp/pip-XYXo6X-record/install-record.txt'
Could not find .egg-info directory in install record for PyYAML==3.12 (from flask-ask)
Running setup.py install for cryptography
Running command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-bui$
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libffi' found
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libffi' found
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libffi' found
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libffi' found
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libffi' found
c/_cffi_backend.c:2:20: fatal error: Python.h: No such file or directory
#include <Python.h>
^
compilation terminated.
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-2gl72v/cryptography/setup.py", line 319, in <module>
**keywords_with_side_effects(sys.argv)
File "/home/pi/.local/lib/python2.7/site-packages/setuptools/__init__.py", line 128,$
_install_setup_requires(attrs)
File "/home/pi/.local/lib/python2.7/site-packages/setuptools/__init__.py", line 123,$
dist.fetch_build_eggs(dist.setup_requires)
File "/home/pi/.local/lib/python2.7/site-packages/setuptools/dist.py", line 514, in $
replace_conflicting=True,
File "/home/pi/.local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 7$
replace_conflicting=replace_conflicting
File "/home/pi/.local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 1$
return self.obtain(req, installer)
File "/home/pi/.local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 1$
return installer(requirement)
File "/home/pi/.local/lib/python2.7/site-packages/setuptools/dist.py", line 581, in $
return cmd.easy_install(req)
File "/home/pi/.local/lib/python2.7/site-packages/setuptools/command/easy_install.py$
return self.install_item(spec, dist.location, tmpdir, deps)
File "/home/pi/.local/lib/python2.7/site-packages/setuptools/command/easy_install.py$
dists = self.install_eggs(spec, download, tmpdir)
File "/home/pi/.local/lib/python2.7/site-packages/setuptools/command/easy_install.py$
return self.build_and_install(setup_script, setup_base)
File "/home/pi/.local/lib/python2.7/site-packages/setuptools/command/easy_install.py$
self.run_setup(setup_script, setup_base, args)
File "/home/pi/.local/lib/python2.7/site-packages/setuptools/command/easy_install.py$
raise DistutilsError("Setup script exited with %s" % (v.args[0],))
distutils.errors.DistutilsError: Setup script exited with error: command 'arm-linux-gn$
Complete output from command /usr/bin/python -c "import setuptools, tokenize;__file__=$
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libffi' found
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libffi' found
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libffi' found
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libffi' found
Package libffi was not found in the pkg-config search path.
Perhaps you should add the directory containing `libffi.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libffi' found
c/_cffi_backend.c:2:20: fatal error: Python.h: No such file or directory
#include <Python.h>
^
compilation terminated.
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-2gl72v/cryptography/setup.py", line 319, in <module>
**keywords_with_side_effects(sys.argv)
File "/home/pi/.local/lib/python2.7/site-packages/setuptools/__init__.py", line 128, in $
_install_setup_requires(attrs)
File "/home/pi/.local/lib/python2.7/site-packages/setuptools/__init__.py", line 123, in $
dist.fetch_build_eggs(dist.setup_requires)
File "/home/pi/.local/lib/python2.7/site-packages/setuptools/dist.py", line 514, in fetc$
replace_conflicting=True,
File "/home/pi/.local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 770, $
replace_conflicting=replace_conflicting
File "/home/pi/.local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 1053,$
return self.obtain(req, installer)
File "/home/pi/.local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 1065,$
return installer(requirement)
File "/home/pi/.local/lib/python2.7/site-packages/setuptools/dist.py", line 581, in fetc$
return cmd.easy_install(req)
File "/home/pi/.local/lib/python2.7/site-packages/setuptools/command/easy_install.py", l$
return self.install_item(spec, dist.location, tmpdir, deps)
File "/home/pi/.local/lib/python2.7/site-packages/setuptools/command/easy_install.py", l$
dists = self.install_eggs(spec, download, tmpdir)
File "/home/pi/.local/lib/python2.7/site-packages/setuptools/command/easy_install.py", l$
return self.build_and_install(setup_script, setup_base)
File "/home/pi/.local/lib/python2.7/site-packages/setuptools/command/easy_install.py", l$
self.run_setup(setup_script, setup_base, args)
File "/home/pi/.local/lib/python2.7/site-packages/setuptools/command/easy_install.py", l$
raise DistutilsError("Setup script exited with %s" % (v.args[0],))
distutils.errors.DistutilsError: Setup script exited with error: command 'arm-linux-gnueab$
----------------------------------------
Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-2gl72v/cr$
Exception information:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 295, in run
requirement_set.install(install_options, global_options, root=options.root_path)
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1436, in install
requirement.install(install_options, global_options, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 707, in install
cwd=self.source_dir, filter_stdout=self._filter_install, show_stdout=False)
File "/usr/lib/python2.7/dist-packages/pip/util.py", line 716, in call_subprocess
% (command_desc, proc.returncode, cwd))
InstallationError: Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/$
I have no clue why this is happening at this point.
I've had luck in a similar situation recently by first updating pip.
sudo apt-get install -y python3-pip
sudo pip3 -H pip3 install --upgrade pip

I am unable to acquire the newest version of pip

When I try to upgrade my pip, using the command prompt, to the newest version I get the errors in the picture below. Is there an administrative step I have overlooked?
An image of my command prompt is located at this link (I don't have a reputation of 10 which is required to include images).
C:\Users\hassa>python -m pip install --upgrade pip
Collecting pip
Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB)
100% |################################| 1.3MB 455kB/s
Installing collected packages: pip
Found existing installation: pip 8.1.2
Uninstalling pip-8.1.2:
Exception:
Traceback (most recent call last):
File "C:\Program Files\Anaconda3\lib\shutil.py", line 538, in move
os.rename(src, real_dst)
PermissionError: [WinError 5] Access is denied: 'c:\\program files\\anaconda3\\lib\\site-packages\\pip' -> 'C:\\Users\\hassa\\AppData\\Local\\Temp\\pip-uazegy0h-uninstall\\program files\\anaconda3\\lib\\site-packages\\pip'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Program Files\Anaconda3\lib\site-packages\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "C:\Program Files\Anaconda3\lib\site-packages\pip\commands\install.py", line 317, in run
prefix=options.prefix_path,
File "C:\Program Files\Anaconda3\lib\site-packages\pip\req\req_set.py", line 736, in install
requirement.uninstall(auto_confirm=True)
File "C:\Program Files\Anaconda3\lib\site-packages\pip\req\req_install.py", line 742, in uninstall
paths_to_remove.remove(auto_confirm)
File "C:\Program Files\Anaconda3\lib\site-packages\pip\req\req_uninstall.py", line 115, in remove
renames(path, new_path)
File "C:\Program Files\Anaconda3\lib\site-packages\pip\utils\__init__.py", line 267, in renames
shutil.move(old, new)
File "C:\Program Files\Anaconda3\lib\shutil.py", line 550, in move
rmtree(src)
File "C:\Program Files\Anaconda3\lib\shutil.py", line 488, in rmtree
return _rmtree_unsafe(path, onerror)
File "C:\Program Files\Anaconda3\lib\shutil.py", line 383, in _rmtree_unsafe
onerror(os.unlink, fullname, sys.exc_info())
File "C:\Program Files\Anaconda3\lib\shutil.py", line 381, in _rmtree_unsafe
os.unlink(fullname)
PermissionError: [WinError 5] Access is denied: 'c:\\program files\\anaconda3\\lib\\site-packages\\pip\\basecommand.py'
You are using pip version 8.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
C:\Users\hassa>
____________________________________
It appears you are using Anaconda. You should use the conda command to update pip in that case:
conda update pip
If that doesn't work, try opening your cmd.exe as Administrator and try again.

Getting an exception while trying to install pip

I want to install praw with pip install praw command but before I want to install pip, couldn't manage to do it.
Collecting pip Using cached pip-9.0.1-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/vv/v2drs0vd7jz6wlywr02cr3480000gn/T/tmpDdYH0a/pip.zip/pip/basecommand.py",
line 215, in main
status = self.run(options, args) File "/var/folders/vv/v2drs0vd7jz6wlywr02cr3480000gn/T/tmpDdYH0a/pip.zip/pip/commands/install.py",
line 342, in run
prefix=options.prefix_path, File "/var/folders/vv/v2drs0vd7jz6wlywr02cr3480000gn/T/tmpDdYH0a/pip.zip/pip/req/req_set.py",
line 784, in install
**kwargs File "/var/folders/vv/v2drs0vd7jz6wlywr02cr3480000gn/T/tmpDdYH0a/pip.zip/pip/req/req_install.py",
line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix) File
"/var/folders/vv/v2drs0vd7jz6wlywr02cr3480000gn/T/tmpDdYH0a/pip.zip/pip/req/req_install.py",
line 1064, in move_wheel_files
isolated=self.isolated, File "/var/folders/vv/v2drs0vd7jz6wlywr02cr3480000gn/T/tmpDdYH0a/pip.zip/pip/wheel.py",
line 345, in move_wheel_files
clobber(source, lib_dir, True) File "/var/folders/vv/v2drs0vd7jz6wlywr02cr3480000gn/T/tmpDdYH0a/pip.zip/pip/wheel.py",
line 316, in clobber
ensure_dir(destdir) File "/var/folders/vv/v2drs0vd7jz6wlywr02cr3480000gn/T/tmpDdYH0a/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'
Seems like you don't have permission to the Python folder.
Try
sudo chown -R $USER /Library/Python/2.7/site-packages/pip
It says it can't write to '/Library/Python/2.7/site-packages/pip'. Adapt read-write rights on that folder or try sudo pip install praw
Try using virtualenv or --user option for pip command
`pip install praw --user`

pip install packages using sudo command

I'm trying to install a virtualenv package -
First, I directly try to install but get permission denied error
Second, the same user(has sudo access) with sudo command tells pip2.7 is not a command.
why is it pip2.7 is visible for the user but not using the sudo command?
[lduser#q-dev-5461-4f3c-9d98-7af28dfc3ec6 bin]$ pip2.7 install virtualenv
Collecting virtualenv
Using cached virtualenv-14.0.6-py2.py3-none-any.whl
Installing collected packages: virtualenv
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/pip/basecommand.py", line 209, in main
status = self.run(options, args)
File "/usr/local/lib/python2.7/site-packages/pip/commands/install.py", line 317, in run
prefix=options.prefix_path,
File "/usr/local/lib/python2.7/site-packages/pip/req/req_set.py", line 731, in install
**kwargs
File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line 841, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line 1040, in move_wheel_files
isolated=self.isolated,
File "/usr/local/lib/python2.7/site-packages/pip/wheel.py", line 343, in move_wheel_files
clobber(source, lib_dir, True)
File "/usr/local/lib/python2.7/site-packages/pip/wheel.py", line 321, in clobber
shutil.copyfile(srcfile, destfile)
File "/usr/local/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/site-packages/virtualenv.pyc'
[duser#q-dev-5461-4f3c-9d98-7af28dfc3ec6 bin]$ sudo pip2.7 install virtualenv
sudo: pip2.7: command not found

python setup.py egg_info gcc error installing cassandra python

For some reason, the specific version that I need to install manually cannot be accessed directly:
rpm -i ftp://195.220.108.108/linux/centos/7.1.1503/updates/x86_64/Packages/python-2.7.5-18.el7_1.1.x86_64.rpm
So tried a brand new installation of python, then tried updating and installing setup tools
yum -y update
yum -y install python-pip
pip install -U pip
pip install -U setuptools
pip install cassandra-driver
yum install patch
then tried
wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
python ez_setup.py
pip install cassandra-driver
Full stacktrace
[root#d8174406546b cassandradump]# pip install cassandra-driver
Collecting cassandra-driver
/usr/lib/python2.7/site-packages/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 validat
ion failures. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#snimissingwarning.
SNIMissingWarning
/usr/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:120: InsecurePlatformWarning: A true SSLContext object is not available. Thi
s prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/e
n/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Using cached cassandra-driver-3.0.0.tar.gz
Complete output from command python setup.py egg_info:
warning: no files found matching '*.pyx' under directory 'Cython/Debugger/Tests'
warning: no files found matching '*.pxd' under directory 'Cython/Debugger/Tests'
warning: no files found matching '*.h' under directory 'Cython/Debugger/Tests'
warning: no files found matching '*.pxd' under directory 'Cython/Utility'
unable to execute gcc: No such file or directory
Unable to find pgen, not compiling formal grammar.
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-cP9FYQ/cassandra-driver/setup.py", line 375, in <module>
run_setup(None)
File "/tmp/pip-build-cP9FYQ/cassandra-driver/setup.py", line 373, in run_setup
**kw)
File "/usr/lib64/python2.7/distutils/core.py", line 112, in setup
_setup_distribution = dist = klass(attrs)
File "/usr/lib/python2.7/site-packages/setuptools/dist.py", line 269, in __init__
self.fetch_build_eggs(attrs['setup_requires'])
File "/usr/lib/python2.7/site-packages/setuptools/dist.py", line 313, in fetch_build_eggs
replace_conflicting=True,
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 827, in resolve
dist = best[req.key] = env.best_match(req, ws, installer)
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 1072, in best_match
return self.obtain(req, installer)
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 1084, in obtain
return installer(requirement)
File "/usr/lib/python2.7/site-packages/setuptools/dist.py", line 380, in fetch_build_egg
return cmd.easy_install(req)
File "/usr/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 640, in easy_install
return self.install_item(spec, dist.location, tmpdir, deps)
File "/usr/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 670, in install_item
dists = self.install_eggs(spec, download, tmpdir)
File "/usr/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 853, in install_eggs
return self.build_and_install(setup_script, setup_base)
File "/usr/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 1081, in build_and_install
self.run_setup(setup_script, setup_base, args)
File "/usr/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 1069, in run_setup
raise DistutilsError("Setup script exited with %s" % (v.args[0],))
distutils.errors.DistutilsError: Setup script exited with error: command 'gcc' failed with exit status 1
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-cP9FYQ/cassandra-driver
Typed enter too early, missed gcc library and got carried away by similar posts.
/tmp/easy_install-N19BCp/Cython-0.23.4/Cython/Plex/Scanners.c:4:20: fatal error: Python.h: No such file or directory
#include "Python.h"
^
compilation terminated.
Unable to find pgen, not compiling formal grammar.
Traceback (most recent call last):
Then python-devel solved the problem.
install yum install python-devel
I am working inside docker so prefixed the 'RUN'. On real systems, you will need to use sudo in place of RUN. Sometimes, the pip is tool old. In my case it was 7.x so I also upgraded it. cython depends on python-devel
RUN pip install --upgrade pip
RUN yum -y install python-devel
RUN pip install cython

Categories

Resources