当我尝试使用 virtualenv 创建新的环境时,遇到了这个错误。我认为不应该使用 sudo 命令运行。尝试使用 brew 重新安装 python,然后使用 virtualenv,但无济于事。
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
/usr/local/bin/easy_install
应该先在路径中,而不是/bin/easy_install
)。请尝试运行brew doctor
并检查路径是否有问题。 - Oliver Charlesworthbrew doctor
提示并提醒我可能会出现一些问题,~/.pydistutils.cfg
。 - yeelan