Virtualenv - IOError:[Errno 1]不允许操作:' / bin / easy_install'

时间:2018-05-16 05:56:00

标签: python macos python-2.7 pip virtualenv

运行此命令时:

$ sudo virtualenv ENV --python=python2.7

我收到以下内容:

Running virtualenv with interpreter /usr/local/bin/python2.7

New python executable in /Users/bo3423/git/My-Project/ENV/bin/python2.7
Not overwriting existing python script /Users/bo3423/git/My-Project/ENV/bin/python (you must use /Users/bo3423/git/My-Project/ENV/bin/python2.7)
Please make sure you remove any previous custom paths from your /Users/bo3423/.pydistutils.cfg file.
Installing setuptools, pip, wheel...
  Complete output from command /Users/bo3423/git/...ie/ENV/bin/python2.7 - setuptools pip wheel:
  The directory '/Users/bo3423/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/bo3423/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
  Downloading https://files.pythonhosted.org/packages/8c/10/79282747f9169f21c053c562a0baa21815a8c7879be97abd930dbcf862e8/setuptools-39.1.0-py2.py3-none-any.whl (566kB)
Collecting pip
  Downloading https://files.pythonhosted.org/packages/0f/74/ecd13431bcc456ed390b44c8a6e917c1820365cbebcb6a8974d1cd045ab4/pip-10.0.1-py2.py3-none-any.whl (1.3MB)
Collecting wheel
  Downloading https://files.pythonhosted.org/packages/81/30/e935244ca6165187ae8be876b6316ae201b71485538ffac1d718843025a9/wheel-0.31.1-py2.py3-none-any.whl (41kB)
Installing collected packages: setuptools, pip, wheel
Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/virtualenv_support/pip-8.0.2-py2.py3-none-any.whl/pip/basecommand.py", line 209, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/virtualenv_support/pip-8.0.2-py2.py3-none-any.whl/pip/commands/install.py", line 317, in run
    prefix=options.prefix_path,
  File "/Library/Python/2.7/site-packages/virtualenv_support/pip-8.0.2-py2.py3-none-any.whl/pip/req/req_set.py", line 731, in install
    **kwargs
  File "/Library/Python/2.7/site-packages/virtualenv_support/pip-8.0.2-py2.py3-none-any.whl/pip/req/req_install.py", line 841, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "/Library/Python/2.7/site-packages/virtualenv_support/pip-8.0.2-py2.py3-none-any.whl/pip/req/req_install.py", line 1040, in move_wheel_files
    isolated=self.isolated,
  File "/Library/Python/2.7/site-packages/virtualenv_support/pip-8.0.2-py2.py3-none-any.whl/pip/wheel.py", line 476, in move_wheel_files
    generated.extend(maker.make(spec))
  File "/Library/Python/2.7/site-packages/virtualenv_support/pip-8.0.2-py2.py3-none-any.whl/pip/_vendor/distlib/scripts.py", line 353, in make
    self._make_script(entry, filenames, options=options)
  File "/Library/Python/2.7/site-packages/virtualenv_support/pip-8.0.2-py2.py3-none-any.whl/pip/_vendor/distlib/scripts.py", line 257, in _make_script
    self._write_script(scriptnames, shebang, script, filenames, ext)
  File "/Library/Python/2.7/site-packages/virtualenv_support/pip-8.0.2-py2.py3-none-any.whl/pip/_vendor/distlib/scripts.py", line 231, in _write_script
    self._fileop.write_binary_file(outname, script_bytes)
  File "/Library/Python/2.7/site-packages/virtualenv_support/pip-8.0.2-py2.py3-none-any.whl/pip/_vendor/distlib/util.py", line 388, 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 "/Library/Python/2.7/site-packages/virtualenv.py", line 2327, in <module>
    main()
  File "/Library/Python/2.7/site-packages/virtualenv.py", line 711, in main
    symlink=options.symlink)
  File "/Library/Python/2.7/site-packages/virtualenv.py", line 944, in create_environment
    download=download,
  File "/Library/Python/2.7/site-packages/virtualenv.py", line 900, in install_wheel
    call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT)
  File "/Library/Python/2.7/site-packages/virtualenv.py", line 795, in call_subprocess
    % (cmd_desc, proc.returncode))
OSError: Command /Users/bo3423/git/...ie/ENV/bin/python2.7 - setuptools pip wheel failed with error code 2

我安装了python2.7但也安装了python3,这可能会导致冲突。我没有成功完全卸载python3。

目录和文件/ bin / easy_install不存在,有没有办法配置virtualenv指向easy_install所在的正确目录?

我在macOS上运行它。任何遇到类似事情的人都会给予您任何帮助!非常感谢!

1 个答案:

答案 0 :(得分:-1)

想出来。删除了所有版本的Python,virtualenv和easy_install。并重新安装除Python3之外的所有内容。