I want to install pymongo on my macosx. Using python -m pip install pymongo, I get this error message :
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-8.1.1-py2.7.egg/pip/basecommand.py", line 209, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-8.1.1-py2.7.egg/pip/commands/install.py", line 317, in run
prefix=options.prefix_path,
File "/Library/Python/2.7/site-packages/pip-8.1.1-py2.7.egg/pip/req/req_set.py", line 732, in install
**kwargs
File "/Library/Python/2.7/site-packages/pip-8.1.1-py2.7.egg/pip/req/req_install.py", line 835, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/Library/Python/2.7/site-packages/pip-8.1.1-py2.7.egg/pip/req/req_install.py", line 1030, in move_wheel_files
isolated=self.isolated,
File "/Library/Python/2.7/site-packages/pip-8.1.1-py2.7.egg/pip/wheel.py", line 344, in move_wheel_files
clobber(source, lib_dir, True)
File "/Library/Python/2.7/site-packages/pip-8.1.1-py2.7.egg/pip/wheel.py", line 315, in clobber
ensure_dir(destdir)
File "/Library/Python/2.7/site-packages/pip-8.1.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/bson'
I get an other error message using easy_install
The following error occurred while trying to add or remove files in the installation directory:
[Errno 13] Permission denied: '/Library/Python/2.7/site-packages/test-easy-install-526.pth'
The installation directory you specified (via --install-dir, --prefix, or the distutils default setting) was:
/Library/Python/2.7/site-packages/
Perhaps 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. 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 PYTHONPATH environment variable.
It's because you're not running it as root. The safest thing to do is use the "user" mode to install your requirements in your home directory.
E.g.:
python -m pip install --user pymongo
Related
I'm trying to create a virtualenv, but I'm getting a Permission denied error. I'm using the following code
python2.7 -m virtualenv -p `which python2.7` test
Which gives this error message:
--edit--
I get a permission denied error
Traceback (most recent call last):
File "/home/marco/.local/lib/python2.7/site-packages/virtualenv_support/pip-9.0.1-py2.py3-none-any.whl/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/home/marco/.local/lib/python2.7/site-packages/virtualenv_support/pip-9.0.1-py2.py3-none-any.whl/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
File "/home/marco/.local/lib/python2.7/site-packages/virtualenv_support/pip-9.0.1-py2.py3-none-any.whl/pip/req/req_set.py", line 784, in install
**kwargs
File "/home/marco/.local/lib/python2.7/site-packages/virtualenv_support/pip-9.0.1-py2.py3-none-any.whl/pip/req/req_install.py", line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/home/marco/.local/lib/python2.7/site-packages/virtualenv_support/pip-9.0.1-py2.py3-none-any.whl/pip/req/req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "/home/marco/.local/lib/python2.7/site-packages/virtualenv_support/pip-9.0.1-py2.py3-none-any.whl/pip/wheel.py", line 345, in move_wheel_files
clobber(source, lib_dir, True)
File "/home/marco/.local/lib/python2.7/site-packages/virtualenv_support/pip-9.0.1-py2.py3-none-any.whl/pip/wheel.py", line 287, in clobber
ensure_dir(dest) # common for the 'include' path
File "/home/marco/.local/lib/python2.7/site-packages/virtualenv_support/pip-9.0.1-py2.py3-none-any.whl/pip/utils/__init__.py", line 83, in ensure_dir
os.makedirs(path)
File "/home/marco/development/openplus/lambda/resizeTestSam/test/lib/python2.7/os.py", line 152, in makedirs
makedirs(head, mode)
File "/home/marco/development/openplus/lambda/resizeTestSam/test/lib/python2.7/os.py", line 159, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/lib/python2.7'
and a final error the operation failed
...Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
File "/home/marco/.local/lib/python2.7/site-packages/virtualenv.py", line 2328, in <module>
main()
File "/home/marco/.local/lib/python2.7/site-packages/virtualenv.py", line 713, in main
symlink=options.symlink)
File "/home/marco/.local/lib/python2.7/site-packages/virtualenv.py", line 945, in create_environment
download=download,
File "/home/marco/.local/lib/python2.7/site-packages/virtualenv.py", line 901, in install_wheel
call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT)
File "/home/marco/.local/lib/python2.7/site-packages/virtualenv.py", line 797, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /home/marco/developm...m/test/bin/python2.7 - setuptools pip wheel failed with error code 2
To debug the error in os.py, I've added a print statement, it looks like the script tries to make the directories /lib/python2.7 and /lib/python2.7/site-packages. I don't understand why virtualenv tries to create these directories there and not in my current directory.
I've installed virtualenv without sudo, so I don't expect it to create directories in a path that is owned by root.
In the end only the python executable is copied to the 'test' directory, but not setuptools, pip and wheels.
Is there a way to avoid virtualenv from accessing root owned directories?
--update--
using python3 with venv works fine, the problem is with virtualenv specifically.
Executing virtualenv from my home directory give no error.
Looks like you're trying to create the virtualenv test within /lib/python2.7/site-packages, which, by all rights, you shouldn't have write access to.
Try running cd ~ first, to create the venv in your home directory.
I had the same mysterious error; it turns out I had forgotten a setting in my $HOME/.pip/pip.conf that changed the prefix.
I'm trying to install python virtualenv.
So i ran the command
pip install virtualenv
and I met these errors.
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 are installing the virtualenv package in a system level directory of a Mac. Mac uses an older Python (2.7.10) that comes pre-installed. To install the virtualenv package in the system directory you identified, you need to use sudo because writing to a system directory requires elevated privileges.
sudo pip install virtualenv
Another option is to install it to a user directory using the --user option.
pip install --user virtualenv
Try running it with sudo:
sudo pip install virtualenv
or else explicitly calling the python command
python -m pip install virtualenv
Funny one today after reinstalling Python 2 on homebrew using brew reinstall python.
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/urllib3’
Relevant stuff
$ which python
/usr/local/bin/python
$ echo $PYTHONPATH
$
Pretty sure this is using the OS X system Python but can't work out how.
Ok - homebrew wants me to use pip2 not pip after reinstall.
I probably should have read the docs, but anyway thats not the main issue...
The top line of the file /usr/local/bin/pip is now
#!/usr/local/opt/python/bin/python2.7
This is the problem. Changing this line to either:
A. #!/usr/local/bin/python or
B. #!`brew --prefix`/bin/python
fixes the problem.
Note: I can't 100% blame this on homebrew. Note sure what happened here but the issue is fixed for me.
Also I could have run sudo pip ... but that would have messed with the macOS system site-packages directory which is generally considered not a great idea.
So, just a quick question. I've installed Pip for Python via Homebrew in the Mac OS X terminal. The next thing I tried to do was install the virtual environment via pip install virtualenv --and that's where I ran into a problem. I get the following error message:
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'
Anyone know what to do?
I'm new to all this, so I'm completely at a loss as to what to do.
Thanks.
Have you seen http://softwaretester.info/install-and-upgrade-pip-on-mac-os-x/
this might help you i am windows user so its command is like pip install package-name but you must present in Scripts folder of the python27 in windows but i don't know about the mac-os-x . so do this also change your directory to python27/scripts and then use your command of pip
If this helps you.Support with thumbs up
I am on ubuntu 14.04 freshly installed, and I have installed pip and virtualenvironment but when I try to install django I get the following error message:
name#computername:/$ pip install django
Collecting django
Using cached Django-1.7.4-py2.py3-none-any.whl
Installing collected packages: django
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/pip-6.0.7-py2.7.egg/pip/basecommand.py", line 232, in main
status = self.run(options, args)
File "/usr/local/lib/python2.7/dist-packages/pip-6.0.7-py2.7.egg/pip/commands/install.py", line 347, in run
root=options.root_path,
File "/usr/local/lib/python2.7/dist-packages/pip-6.0.7-py2.7.egg/pip/req/req_set.py", line 549, in install
**kwargs
File "/usr/local/lib/python2.7/dist-packages/pip-6.0.7-py2.7.egg/pip/req/req_install.py", line 740, in install
self.move_wheel_files(self.source_dir, root=root)
File "/usr/local/lib/python2.7/dist-packages/pip-6.0.7-py2.7.egg/pip/req/req_install.py", line 949, in move_wheel_files
isolated=self.isolated,
File "/usr/local/lib/python2.7/dist-packages/pip-6.0.7-py2.7.egg/pip/wheel.py", line 234, in move_wheel_files
clobber(source, lib_dir, True)
File "/usr/local/lib/python2.7/dist-packages/pip-6.0.7-py2.7.egg/pip/wheel.py", line 205, in clobber
os.makedirs(destdir)
File "/usr/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/django'
It does, however work when I try installing on a venv.
Could this have anything to do with $PYTHONPATH?
(I believe this is also causing conflicts when I try to run runserver on an already started project. But I will leave that for another question if this one doesn't resolve it.)
You need to activate your virtual environment first.
$ source PATH_TO_ENV/bin/env
$ pip install django
In a newly created virtualenv there will also be a activate shell script. For Windows systems, activation scripts are provided for the Command Prompt and Powershell.
On Posix systems, this resides in /ENV/bin/
Unless you do this you are using system python and system libs. That's why you see the error.
If you need to install a lib into the system scope you need root access:
$ sudo pip install django