virtualenv无法创建环境

时间:2019-11-24 19:40:12

标签: python-3.x pip virtualenv

我正在运行最新版本的Catalina的iMac上运行。我通过自制软件安装了python 3.7.5。到目前为止,我一直在使用sudo -H pip3 install ...安装软件包。

我想使用virtualenv。我安装了virtualenv版本16.7.8。但是,当我尝试在文件系统中创建新的virtualenv时,经过许多有关在pythonhosted上查找文件的工作之后,我得到了下面的跟踪。显然,它正在尝试创建/ lib的子目录!这看起来像某种错误。关于跟踪它有什么建议吗?它创建了bin,lib和include子目录,但只有lib中有任何文件。

Using base prefix '/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7'
New python executable in /Users/victorsmiller/Programming/Python/tst/bin/python3.7
Also creating executable in /Users/victorsmiller/Programming/Python/tst/bin/python
Please make sure you remove any previous custom paths from your /Users/victorsmiller/.pydistutils.cfg file.
Installing setuptools, pip, wheel...

  Complete output from command /Users/victorsmiller...on/tst/bin/python3.7 - setuptools pip wheel:
  Created temporary directory: /private/var/folders/zs/sfhqf6rs4dgdjf89wmqsc6440000gn/T/pip-ephem-wheel-cache-2_g3dz1c
Created temporary directory: /private/var/folders/zs/sfhqf6rs4dgdjf89wmqsc6440000gn/T/pip-req-tracker-bxfcy5h6
Created requirements tracker '/private/var/folders/zs/sfhqf6rs4dgdjf89wmqsc6440000gn/T/pip-req-tracker-bxfcy5h6'
Created temporary directory: /private/var/folders/zs/sfhqf6rs4dgdjf89wmqsc6440000gn/T/pip-install-oboxx8ib
Looking in links: /usr/local/lib/python3.7/site-packages/virtualenv_support
1 location(s) to search for versions of setuptools:
* https://pypi.org/simple/setuptools/
Getting page https://pypi.org/simple/setuptools/
Found index url https://pypi.org/simple
Looking up "https://pypi.org/simple/setuptools/" in the cache
Request header has "max_age" as 0, cache bypassed
Starting new HTTPS connection (1): pypi.org:443
https://pypi.org:443 "GET /simple/setuptools/ HTTP/1.1" 304 0
Skipping link: not a file: /usr/local/lib/python3.7/site-packages/virtualenv_support (from -f)
Analyzing links from page https://pypi.org/simple/setuptools/
  Skipping link: unsupported archive format: .egg: https://files.pythonhosted.org/packages/77/38/90cae8fd99c5dc402d25930e1c91f5fcf6de5c8e982fd152a5a061e3df56/setuptools-0.6b1-py2.3.egg#sha256=ae0a6ec6090a92d08fe7f3dbf9f1b2ce889bce2a3d7724b62322a29b92cf93f0 (from https://pypi.org/simple/setuptools/)

,然后有很多类似的最后一行。然后是:

Local files found: /usr/local/lib/python3.7/site-packages/virtualenv_support/setuptools-41.6.0-py2.py3-none-any.whl
Given no hashes to check 305 links for project 'setuptools': discarding no candidates
Using version 42.0.0 (newest of versions: 0.9.8, 1.1.6, 1.2, 1.3, 1.3.1, 1.3.2, 1.4, 1.4.1, 1.4.2, 2.0, 2.0.1, 2.0.2, 2.1, 2.1.2, 2.2, 3.1, 3.2, 3.3, 3.4, 3.4.1, 3.4.2, 3.4.3, 3.4.4, 3.5, 3.5.1, 3.5.2, 3.6, 3.7, 3.7.1, 3.8, 3.8.1, 5.0, 5.0.1, 5.0.2, 5.1, 5.2, 5.3, 5.4, 5.4.1, 5.4.2, 5.5, 5.5.1, 5.6, 5.7, 5.8, 6.0.1, 6.0.2, 6.1, 7.0, 8.0, 8.0.1, 8.0.2, 8.0.3, 8.0.4, 8.1, 8.2, 8.2.1, 8.3, 9.0, 9.0.1, 9.1, 10.0, 10.0.1, 10.1, 10.2, 10.2.1, 11.0, 11.1, 11.2, 11.3, 11.3.1, 12.0, 12.0.1, 12.0.2, 12.0.3, 12.0.4, 12.0.5, 12.1, 12.2, 12.3, 12.4, 13.0.1, 13.0.2, 14.0, 14.1, 14.1.1, 14.2, 14.3, 14.3.1, 15.0, 15.1, 15.2, 16.0, 17.0, 17.1, 17.1.1, 18.0, 18.0.1, 18.1, 18.2, 18.3, 18.3.1, 18.3.2, 18.4, 18.5, 18.6, 18.6.1, 18.7, 18.7.1, 18.8, 18.8.1, 19.0, 19.1, 19.1.1, 19.2, 19.3, 19.4, 19.4.1, 19.5, 19.6, 19.6.1, 19.6.2, 19.7, 20.0, 20.1, 20.1.1, 20.2.2, 20.3, 20.3.1, 20.4, 20.6.6, 20.6.7, 20.6.8, 20.7.0, 20.8.0, 20.8.1, 20.9.0, 20.10.1, 21.0.0, 21.1.0, 21.2.0, 21.2.1, 21.2.2, 22.0.0, 22.0.1, 22.0.2, 22.0.4, 22.0.5, 23.0.0, 23.1.0, 23.2.0, 23.2.1, 24.0.0, 24.0.1, 24.0.2, 24.0.3, 24.1.0, 24.1.1, 24.2.0, 24.2.1, 24.3.0, 24.3.1, 25.0.0, 25.0.1, 25.0.2, 25.1.0, 25.1.1, 25.1.2, 25.1.3, 25.1.4, 25.1.5, 25.1.6, 25.2.0, 25.3.0, 25.4.0, 26.0.0, 26.1.0, 26.1.1, 27.0.0, 27.1.0, 27.1.2, 27.2.0, 27.3.0, 27.3.1, 28.0.0, 28.1.0, 28.2.0, 28.3.0, 28.4.0, 28.5.0, 28.6.0, 28.6.1, 28.7.0, 28.7.1, 28.8.0, 28.8.1, 29.0.0, 29.0.1, 30.0.0, 30.1.0, 30.2.0, 30.2.1, 30.3.0, 30.4.0, 31.0.0, 31.0.1, 32.0.0, 32.1.0, 32.1.1, 32.1.2, 32.1.3, 32.2.0, 32.3.0, 32.3.1, 33.1.0, 33.1.1, 34.0.0, 34.0.1, 34.0.2, 34.0.3, 34.1.0, 34.1.1, 34.2.0, 34.3.0, 34.3.1, 34.3.2, 34.3.3, 34.4.0, 34.4.1, 35.0.0, 35.0.1, 35.0.2, 36.0.1, 36.1.0, 36.1.1, 36.2.0, 36.2.1, 36.2.2, 36.2.3, 36.2.4, 36.2.5, 36.2.6, 36.2.7, 36.3.0, 36.4.0, 36.5.0, 36.6.0, 36.6.1, 36.7.0, 36.7.1, 36.7.2, 36.8.0, 37.0.0, 38.0.0, 38.1.0, 38.2.0, 38.2.1, 38.2.3, 38.2.4, 38.2.5, 38.3.0, 38.4.0, 38.4.1, 38.5.0, 38.5.1, 38.5.2, 38.6.0, 38.6.1, 38.7.0, 39.0.0, 39.0.1, 39.1.0, 39.2.0, 40.0.0, 40.1.0, 40.1.1, 40.2.0, 40.3.0, 40.4.0, 40.4.1, 40.4.2, 40.4.3, 40.5.0, 40.6.0, 40.6.1, 40.6.2, 40.6.3, 40.7.0, 40.7.1, 40.7.2, 40.7.3, 40.8.0, 40.9.0, 41.0.0, 41.0.1, 41.1.0, 41.2.0, 41.3.0, 41.4.0, 41.5.0, 41.5.1, 41.6.0, 42.0.0)
Collecting setuptools
  Created temporary directory: /private/var/folders/zs/sfhqf6rs4dgdjf89wmqsc6440000gn/T/pip-unpack-qj_9img3
  Looking up "https://files.pythonhosted.org/packages/61/a2/82b506a6cdb42cc79a65d5a9e790112cf6b98ee7aba4a53a2b9c9c8047d0/setuptools-42.0.0-py2.py3-none-any.whl" in the cache
  Current age based on date: 3817
  Ignoring unknown cache-control directive: immutable
  Freshness lifetime from max-age: 365000000
  The response is "fresh", returning cached response
  365000000 > 3817
  Using cached https://files.pythonhosted.org/packages/61/a2/82b506a6cdb42cc79a65d5a9e790112cf6b98ee7aba4a53a2b9c9c8047d0/setuptools-42.0.0-py2.py3-none-any.whl
  Added setuptools from https://files.pythonhosted.org/packages/61/a2/82b506a6cdb42cc79a65d5a9e790112cf6b98ee7aba4a53a2b9c9c8047d0/setuptools-42.0.0-py2.py3-none-any.whl#sha256=4248cb506794bececcddeddb1678bc722f9cfcacf02f98f7c0af6b9ed893caf2 to build tracker '/private/var/folders/zs/sfhqf6rs4dgdjf89wmqsc6440000gn/T/pip-req-tracker-bxfcy5h6'
  Removed setuptools from https://files.pythonhosted.org/packages/61/a2/82b506a6cdb42cc79a65d5a9e790112cf6b98ee7aba4a53a2b9c9c8047d0/setuptools-42.0.0-py2.py3-none-any.whl#sha256=4248cb506794bececcddeddb1678bc722f9cfcacf02f98f7c0af6b9ed893caf2 from build tracker '/private/var/folders/zs/sfhqf6rs4dgdjf89wmqsc6440000gn/T/pip-req-tracker-bxfcy5h6'
1 location(s) to search for versions of pip:
* https://pypi.org/simple/pip/
Getting page https://pypi.org/simple/pip/
Found index url https://pypi.org/simple
Looking up "https://pypi.org/simple/pip/" in the cache
Request header has "max_age" as 0, cache bypassed
https://pypi.org:443 "GET /simple/pip/ HTTP/1.1" 304 0
Analyzing links from page https://pypi.org/simple/pip/
  Skipping link: No sources permitted for pip: https://files.pythonhosted.org/packages/3d/9d/1e313763bdfb6a48977b65829c6ce2a43eaae29ea2f907c8bbef024a7219/pip-0.2.tar.gz#sha256=88bb8d029e1bf4acd0e04d300104b7440086f94cc1ce1c5c3c31e3293aee1f81 (from https://pypi.org/simple/pip/)

以及与上一行相似的更多行,其后是

Found link file:///usr/local/lib/python3.7/site-packages/virtualenv_support/wheel-0.33.6-py2.py3-none-any.whl, version: 0.33.6
Local files found: /usr/local/lib/python3.7/site-packages/virtualenv_support/wheel-0.33.6-py2.py3-none-any.whl
Given no hashes to check 37 links for project 'wheel': discarding no candidates
Using version 0.33.6 (newest of versions: 0.9, 0.9.5, 0.10.0, 0.10.1, 0.10.2, 0.10.3, 0.11.0, 0.12.0, 0.13.0, 0.14.0, 0.15.0, 0.16.0, 0.17.0, 0.18.0, 0.19.0, 0.21.0, 0.22.0, 0.23.0, 0.24.0, 0.25.0, 0.26.0, 0.27.0, 0.28.0, 0.29.0, 0.30.0, 0.31.0, 0.31.1, 0.32.0, 0.32.1, 0.32.2, 0.32.3, 0.33.0, 0.33.1, 0.33.4, 0.33.5, 0.33.6)
Processing /usr/local/lib/python3.7/site-packages/virtualenv_support/wheel-0.33.6-py2.py3-none-any.whl
  Added wheel from file:///usr/local/lib/python3.7/site-packages/virtualenv_support/wheel-0.33.6-py2.py3-none-any.whl to build tracker '/private/var/folders/zs/sfhqf6rs4dgdjf89wmqsc6440000gn/T/pip-req-tracker-bxfcy5h6'
  Removed wheel from file:///usr/local/lib/python3.7/site-packages/virtualenv_support/wheel-0.33.6-py2.py3-none-any.whl from build tracker '/private/var/folders/zs/sfhqf6rs4dgdjf89wmqsc6440000gn/T/pip-req-tracker-bxfcy5h6'
Installing collected packages: setuptools, pip, wheel

ERROR: Could not install packages due to an EnvironmentError.
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/virtualenv_support/pip-19.3.1-py2.py3-none-any.whl/pip/_internal/commands/install.py", line 455, in run
    use_user_site=options.use_user_site,
  File "/usr/local/lib/python3.7/site-packages/virtualenv_support/pip-19.3.1-py2.py3-none-any.whl/pip/_internal/req/__init__.py", line 62, in install_given_reqs
    **kwargs
  File "/usr/local/lib/python3.7/site-packages/virtualenv_support/pip-19.3.1-py2.py3-none-any.whl/pip/_internal/req/req_install.py", line 861, in install
    use_user_site=use_user_site, pycompile=pycompile,
  File "/usr/local/lib/python3.7/site-packages/virtualenv_support/pip-19.3.1-py2.py3-none-any.whl/pip/_internal/req/req_install.py", line 495, in move_wheel_files
    warn_script_location=warn_script_location,
  File "/usr/local/lib/python3.7/site-packages/virtualenv_support/pip-19.3.1-py2.py3-none-any.whl/pip/_internal/wheel.py", line 461, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/usr/local/lib/python3.7/site-packages/virtualenv_support/pip-19.3.1-py2.py3-none-any.whl/pip/_internal/wheel.py", line 392, in clobber
    ensure_dir(dest)  # common for the 'include' path
  File "/usr/local/lib/python3.7/site-packages/virtualenv_support/pip-19.3.1-py2.py3-none-any.whl/pip/_internal/utils/misc.py", line 116, in ensure_dir
    os.makedirs(path)
  File "/Users/victorsmiller/Programming/Python/tst/bin/../lib/python3.7/os.py", line 211, in makedirs
    makedirs(head, exist_ok=exist_ok)
  File "/Users/victorsmiller/Programming/Python/tst/bin/../lib/python3.7/os.py", line 211, in makedirs
    makedirs(head, exist_ok=exist_ok)
  File "/Users/victorsmiller/Programming/Python/tst/bin/../lib/python3.7/os.py", line 221, in makedirs
    mkdir(name, mode)
OSError: [Errno 30] Read-only file system: '/lib'
Cleaning up...
Removed build tracker '/private/var/folders/zs/sfhqf6rs4dgdjf89wmqsc6440000gn/T/pip-req-tracker-bxfcy5h6'

3 个答案:

答案 0 :(得分:1)

我只是遇到了这个问题,它似乎是特定于> = 16.7.0的版本的。降级到16.6.2版已为我修复:pip install virtualenv==16.6.2

答案 1 :(得分:0)

检查并取消注释/Users/<USER_NAME>/.pydistutils.cfg的内容

答案 2 :(得分:0)

发现我的失败原因-先前的dist命令创建了setup.cfg文件,其中包含:

[install]
prefix=

删除或注释掉这些行可以解决问题。