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
Related
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
im trying to install autopep8 using pip install. I am getting a permission denied when its trying to install pycodestyle
Collecting autopep8
Using cached autopep8-1.3.2-py2.py3-none-any.whl
Collecting pycodestyle>=2.3 (from autopep8)
Using cached pycodestyle-2.3.1-py2.py3-none-any.whl
Installing collected packages: pycodestyle, autopep8
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 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/pycodestyle.py'
You don't have a problem with python but with your user's permissions on the linux box.
Try sudo pip install package instead of just pip install package.
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.
Here's the output of my shell:
Hannahs-MacBook-Pro:Downloads hannah$ pip install virtualenv
Collecting virtualenv
Downloading virtualenv-15.1.0-py2.py3-none-any.whl (1.8MB)
100% |████████████████████████████████| 1.8MB 195kB/s
Installing collected packages: virtualenv
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 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/virtualenv.py'
You need root access to install (or update) virtualenv, try:
sudo pip install virtualenv
IOError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/virtualenv.py'
You don't have permission to install, use sudo pip install virtualenv.
Whenever you get this error IOError: [Errno 13] Permission denied:, it means that you need to use sudo.
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`