Dan Rubio
Dan Rubio

Reputation: 4907

pip install no longer works with virtualenv, somehow pip is trying to install with root

------EDIT Starting Over again ---------

I have a problem with virtualenv and I'm not sure how I caused it. The problem that I am having is that I cannot install any flask-extensions onto my flask application's site-packages directory.

I had a previous stackoverflow question that I overwrote before but I believe that I found the root problem and the problem is in virtualenv itself. Here is an error that I get when executing virtualenv env:

New python executable in env/bin/python
Please make sure you remove any previous custom paths from your /Users/drubio/.pydistutils.cfg file.
Installing setuptools, pip, wheel...
  Complete output from command /Users/drubio/example/env/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip wheel:
  Ignoring indexes: https://pypi.python.org/simple
The directory '/Users/drubio/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/drubio/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
Collecting pip
Collecting wheel
Installing collected packages: setuptools, pip, wheel
Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/virtualenv-13.1.2-py2.7.egg/virtualenv_support/pip-7.1.2-py2.py3-none-any.whl/pip/basecommand.py", line 211, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/virtualenv-13.1.2-py2.7.egg/virtualenv_support/pip-7.1.2-py2.py3-none-any.whl/pip/commands/install.py", line 311, in run
    root=options.root_path,
  File "/Library/Python/2.7/site-packages/virtualenv-13.1.2-py2.7.egg/virtualenv_support/pip-7.1.2-py2.py3-none-any.whl/pip/req/req_set.py", line 646, in install
    **kwargs
  File "/Library/Python/2.7/site-packages/virtualenv-13.1.2-py2.7.egg/virtualenv_support/pip-7.1.2-py2.py3-none-any.whl/pip/req/req_install.py", line 803, in install
    self.move_wheel_files(self.source_dir, root=root)
  File "/Library/Python/2.7/site-packages/virtualenv-13.1.2-py2.7.egg/virtualenv_support/pip-7.1.2-py2.py3-none-any.whl/pip/req/req_install.py", line 998, in move_wheel_files
    isolated=self.isolated,
  File "/Library/Python/2.7/site-packages/virtualenv-13.1.2-py2.7.egg/virtualenv_support/pip-7.1.2-py2.py3-none-any.whl/pip/wheel.py", line 339, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/Library/Python/2.7/site-packages/virtualenv-13.1.2-py2.7.egg/virtualenv_support/pip-7.1.2-py2.py3-none-any.whl/pip/wheel.py", line 282, in clobber
    ensure_dir(dest)  # common for the 'include' path
  File "/Library/Python/2.7/site-packages/virtualenv-13.1.2-py2.7.egg/virtualenv_support/pip-7.1.2-py2.py3-none-any.whl/pip/utils/__init__.py", line 71, in ensure_dir
    os.makedirs(path)
  File "/Users/drubio/example/env/lib/python2.7/os.py", line 150, in makedirs
    makedirs(head, mode)
  File "/Users/drubio/example/env/lib/python2.7/os.py", line 150, in makedirs
    makedirs(head, mode)
  File "/Users/drubio/example/env/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/lib'
----------------------------------------
...Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
  File "/usr/local/bin/virtualenv", line 9, in <module>
    load_entry_point('virtualenv==13.1.2', 'console_scripts', 'virtualenv')()
  File "/Library/Python/2.7/site-packages/virtualenv-13.1.2-py2.7.egg/virtualenv.py", line 832, in main
    symlink=options.symlink)
  File "/Library/Python/2.7/site-packages/virtualenv-13.1.2-py2.7.egg/virtualenv.py", line 1004, in create_environment
    install_wheel(to_install, py_executable, search_dirs)
  File "/Library/Python/2.7/site-packages/virtualenv-13.1.2-py2.7.egg/virtualenv.py", line 969, in install_wheel
    'PIP_NO_INDEX': '1'
  File "/Library/Python/2.7/site-packages/virtualenv-13.1.2-py2.7.egg/virtualenv.py", line 910, in call_subprocess
    % (cmd_desc, proc.returncode))

There is some sort of permission that is being denied in /lib and I'm not sure what that means. Is there a way to completely remove virtualenv. The bin directory for a new application does not contain an activate file or anything.

Also, running these commands result in the following:

(sudo) pip uninstall virtualenv
 zsh: /bin/pip: bad interpreter: /usr/local/opt/python/bin/python2.7: no such file or directory
 sudo: unable to execute /bin/pip: No such file or directory

However when I execute which virtualenv and which pip I clearly have them under /usr/local/bin/virtualenv/ and /bin/pip.

Any thoughts?

Upvotes: 1

Views: 2164

Answers (1)

Dan Rubio
Dan Rubio

Reputation: 4907

I found the problem! The problem was in this file /Users/drubio/.pydistutils.cfg

For another problem I had (which I can't remember) I needed to place these two lines for a work around:

[install]
prefix=''

Removing those lines made it work.

Upvotes: 1

Related Questions