9

I'm new to Python development and I'm trying to instal virtualenv in my project directory.

However I have the following error:

Installing collected packages: pip, setuptools Exception: Traceback (most recent call last): File "/Library/Python/2.7/site-packages/virtualenv_support/pip-6.0.8-py2.py3-none-any.whl/pip/basecommand.py", line 232, in main status = self.run(options, args) File "/Library/Python/2.7/site-packages/virtualenv_support/pip-6.0.8-py2.py3-none-any.whl/pip/commands/install.py", line 347, in run root=options.root_path, File "/Library/Python/2.7/site-packages/virtualenv_support/pip-6.0.8-py2.py3-none-any.whl/pip/req/req_set.py", line 549, in install **kwargs File "/Library/Python/2.7/site-packages/virtualenv_support/pip-6.0.8-py2.py3-none-any.whl/pip/req/req_install.py", line 754, in install self.move_wheel_files(self.source_dir, root=root) File "/Library/Python/2.7/site-packages/virtualenv_support/pip-6.0.8-py2.py3-none-any.whl/pip/req/req_install.py", line 963, in move_wheel_files isolated=self.isolated, File "/Library/Python/2.7/site-packages/virtualenv_support/pip-6.0.8-py2.py3-none-any.whl/pip/wheel.py", line 234, in move_wheel_files clobber(source, lib_dir, True) File "/Library/Python/2.7/site-packages/virtualenv_support/pip-6.0.8-py2.py3-none-any.whl/pip/wheel.py", line 212, in clobber shutil.copyfile(srcfile, destfile) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 82, in copyfile with open(dst, 'wb') as fdst: IOError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/pip/__init__.py' ---------------------------------------- ...Installing setuptools, pip...done. Traceback (most recent call last): File "/usr/local/bin/virtualenv", line 11, in <module> sys.exit(main()) File "/Library/Python/2.7/site-packages/virtualenv.py", line 825, in main symlink=options.symlink) File "/Library/Python/2.7/site-packages/virtualenv.py", line 993, in create_environment install_wheel(to_install, py_executable, search_dirs) File "/Library/Python/2.7/site-packages/virtualenv.py", line 961, in install_wheel 'PIP_NO_INDEX': '1' File "/Library/Python/2.7/site-packages/virtualenv.py", line 903, in call_subprocess % (cmd_desc, proc.returncode)) OSError: Command /Users/alexandrurada...oard/venv/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip failed with error code 2 

I installed pip with

easy_install pip

Then I installed virtualenv with

pip install virtualenv

Without any errors. However I'm still getting this. I didn't want to try it with sudo. Should I?

UPDATE: I installed them with sudo, and I got rid of this error. However another one when trying to install something with pip:

air:dashboard alexandrurada$ pip install flask 

-bash: /usr/local/bin/pip: "path_here": bad interpreter: No such file or directory

UPDATE 2: The earlier error was because of a space inside a directory name. Looks like path doesn't work with such names.

Anyway, the error I'm getting now is

File "/usr/local/bin/pip", line 7, in <module> from pip import main ImportError: No module named pip 

I checked my /usr/local/bin/pip and the file exists.

1
  • Do you have needed privileges? You may need to run sudo your_cmd Commented Feb 8, 2015 at 14:45

2 Answers 2

15

You need sudo pip install virtualenv to install virtualenv globally. When setting up your virtualenvs make sure you don't use sudo and that you activate your virtualenv before trying to install.

[Errno 13] Permission denied: means you don't have write permissions.

Sign up to request clarification or add additional context in comments.

2 Comments

You save my day !
Win10 PowerShell pip install virtualenv as admin
4

Install a newer version of pip and avoid using easy_install.

Download pip from: https://bootstrap.pypa.io/get-pip.py

and then run Python on it:

$ python get-pip.py 

If you want to install pip to the global path, you likely want to run that last command with sudo. Without using sudo, pip will get installed for use with whatever Python interpreter is in your path.

From here, you can install virtualenv with pip:

$ pip install virtualenv 

From your responses, it seems like you'd be best served by getting your system in a known state: Download that file, then run sudo python get-pip.py so you're running with a known-working pip install.

6 Comments

I did this and after activating venv, I get global pip path using which pip (which python shows the local one)
@AlexandruRada What are you trying to accomplish?
I'm trying to start my first project in python. I read about virtualenv and I want it installed. However, even with global pip directory I get an error: -bash: /usr/local/bin/pip: bad interpreter: No such file or directory when running for example pip install flask
Ah, alright then. You likely want to run my instructions with sudo. Download that file, then run sudo python get-pip.py and you should be in better shape.
I did this and I manage to fix the error with no such file (it was a space in a directory name and seems that was the issue). Now, every pip install I'm trying shows me: File "/usr/local/bin/pip", line 7, in <module> from pip import main ImportError: No module named pip
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.