【问题标题】:virtualenv error on os Xos X上的virtualenv错误
【发布时间】:2016-03-27 17:12:38
【问题描述】:

当我尝试使用 virtualenv 创建新环境时,我遇到了这个错误。我认为我不应该使用 sudo 运行该命令。已尝试使用 brew & then virtualenv 重新安装 python,但没有什么可挽救的。

manishs-MacBook-Pro:manish Manish$ virtualenv manish

New python executable in /Users/Manish/manish/manish/bin/python2.7
Not overwriting existing python script /Users/Manish/manish/manish/bin/python (you must use /Users/Manish/manish/manish/bin/python2.7)
Please make sure you remove any previous custom paths from your /Users/Manish/.pydistutils.cfg file.
Installing setuptools, pip, wheel...
  Complete output from command /Users/Manish/manish/manish/bin/python2.7 - setuptools pip wheel:
  Collecting setuptools
  Using cached setuptools-20.3.1-py2.py3-none-any.whl
Collecting pip
Collecting wheel
Installing collected packages: setuptools, pip, wheel
Exception:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/virtualenv_support/pip-8.1.1-py2.py3-none-any.whl/pip/basecommand.py", line 209, in main
    status = self.run(options, args)
  File "/usr/local/lib/python2.7/site-packages/virtualenv_support/pip-8.1.1-py2.py3-none-any.whl/pip/commands/install.py", line 317, in run
    prefix=options.prefix_path,
  File "/usr/local/lib/python2.7/site-packages/virtualenv_support/pip-8.1.1-py2.py3-none-any.whl/pip/req/req_set.py", line 732, in install
    **kwargs
  File "/usr/local/lib/python2.7/site-packages/virtualenv_support/pip-8.1.1-py2.py3-none-any.whl/pip/req/req_install.py", line 835, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "/usr/local/lib/python2.7/site-packages/virtualenv_support/pip-8.1.1-py2.py3-none-any.whl/pip/req/req_install.py", line 1030, in move_wheel_files
    isolated=self.isolated,
  File "/usr/local/lib/python2.7/site-packages/virtualenv_support/pip-8.1.1-py2.py3-none-any.whl/pip/wheel.py", line 477, in move_wheel_files
    generated.extend(maker.make(spec))
  File "/usr/local/lib/python2.7/site-packages/virtualenv_support/pip-8.1.1-py2.py3-none-any.whl/pip/_vendor/distlib/scripts.py", line 372, in make
    self._make_script(entry, filenames, options=options)
  File "/usr/local/lib/python2.7/site-packages/virtualenv_support/pip-8.1.1-py2.py3-none-any.whl/pip/_vendor/distlib/scripts.py", line 276, in _make_script
    self._write_script(scriptnames, shebang, script, filenames, ext)
  File "/usr/local/lib/python2.7/site-packages/virtualenv_support/pip-8.1.1-py2.py3-none-any.whl/pip/_vendor/distlib/scripts.py", line 250, in _write_script
    self._fileop.write_binary_file(outname, script_bytes)
  File "/usr/local/lib/python2.7/site-packages/virtualenv_support/pip-8.1.1-py2.py3-none-any.whl/pip/_vendor/distlib/util.py", line 401, in write_binary_file
    with open(path, 'wb') as f:
IOError: [Errno 1] Operation not permitted: '/bin/easy_install'
----------------------------------------
...Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
  File "/usr/local/bin/virtualenv", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/site-packages/virtualenv.py", line 708, in main
    symlink=options.symlink)
  File "/usr/local/lib/python2.7/site-packages/virtualenv.py", line 941, in create_environment
    download=download,
  File "/usr/local/lib/python2.7/site-packages/virtualenv.py", line 897, in install_wheel
    call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT)
  File "/usr/local/lib/python2.7/site-packages/virtualenv.py", line 792, in call_subprocess
    % (cmd_desc, proc.returncode))
OSError: Command /Users/Manish/manish/manish/bin/python2.7 - setuptools pip wheel failed with error code 2

【问题讨论】:

  • 可能您安装了两个 Python(一个在系统级别,另一个通过 Homebrew - 通常 /usr/local/bin/easy_install 应该首先在路径上,而不是 /bin/easy_install)。您可以尝试运行brew doctor 并检查有关路径的投诉吗?
  • brew doctorhelps 并提示我~/.pydistutils.cfg 可能会导致一些问题。

标签: python macos virtualenv


【解决方案1】:

我删除了~/.pydistutils.cfg,它成功了

【讨论】:

  • 这背后的想法是什么?
  • 如果您在项目根目录中有setup.cfg,请尝试将其删除。为我工作。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-12-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-06-22
  • 1970-01-01
  • 2011-01-22
相关资源
最近更新 更多