pipinstall不再使用virtualenv,不知何故,pip正试图使用root进行安装



------编辑重新开始--------

我对virtualenv有一个问题,我不确定是怎么造成的。我遇到的问题是,我无法在flask应用程序的站点包目录上安装任何flask扩展。

我之前有一个stackoverflow问题,我之前已经重写了,但我相信我找到了根本问题,问题就在virtualenv本身。以下是我在执行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))

/lib中有某种权限被拒绝,我不确定这意味着什么。有没有一种方法可以完全删除virtualenv。新应用程序的bin目录不包含激活文件或任何内容。

此外,运行这些命令会产生以下结果:

(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

然而,当我执行which virtualenvwhich pip时,我清楚地将它们置于/usr/local/bin/virtualenv//bin/pip之下。

有什么想法吗?

我发现了问题!问题出现在此文件/Users/drubio/.pydistutils.cfg

对于我遇到的另一个问题(我记不清了),我需要放置这两行来解决:

[install]
prefix=''

去掉这些线就成功了。

最新更新