无法安装虚拟python环境

时间:2017-09-12 12:04:13

标签: opencv virtualenv homebrew macos-sierra virtualenvwrapper

我正在尝试在macOS Sierra中通过Homebrew安装和使用带有Python 3的opencv。我按照this tutorial中的步骤操作,但在输入命令pip install virtualenv virtualenvwrapper后,我得到了如下所示的异常。

当我第一次尝试安装虚拟环境时,它说它找不到pip。我使用sudo easy_install pip并再次键入所需的命令行。

Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py", line 342, in run
    prefix=options.prefix_path,
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 784, in install
    **kwargs
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 851, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 1064, in move_wheel_files
    isolated=self.isolated,
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/wheel.py", line 345, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/wheel.py", line 323, in clobber
    shutil.copyfile(srcfile, destfile)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 83, in copyfile
    with open(dst, 'wb') as fdst:
IOError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/virtualenv.py'

但是在使用pipinstall --user virtualenv virtualenvwrapper之后它很顺利。但在将源代码更新为给定here并获取后,我会得到以下-bash: /usr/local/bin/virtualenvwrapper.sh: No such file or directory

即使我关闭终端并在第二行重新打开它,我看到了 -bash: /usr/local/bin/virtualenvwrapper.sh: No such file or directory

请帮助我:(

1 个答案:

答案 0 :(得分:1)

这是许可问题。按照here所述,您应该使用--user选项:

pip install --user virtualenv virtualenvwrapper