如何在我的Mac上正确安装virtualenvwrapper?

时间:2019-06-15 14:14:20

标签: python django virtualenv virtualenvwrapper

我正在尝试遵循Mozilla Django指南:

https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django/development_environment

按照指南中的步骤,我已经成功安装了Python3.7.3和pip3。当我输入python3 -Vpip3 list时,将得到预期的响应。

步骤1

下一步是安装 virtualenvwrapper 。我使用推荐的命令来做到这一点:

sudo pip3 install virtualenvwrapper

但是当我按下Enter键时,我收到以下警告:

The directory '/Users/myusername/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/myusername/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 virtualenvwrapper
  Downloading https://files.pythonhosted.org/packages/c1/6b/2f05d73b2d2f2410b48b90d3783a0034c26afa534a4a95ad5f1178d61191/virtualenvwrapper-4.8.4.tar.gz (334kB)
    100% |████████████████████████████████| 337kB 9.9MB/s 
Collecting virtualenv (from virtualenvwrapper)
  Downloading https://files.pythonhosted.org/packages/ca/ee/8375c01412abe6ff462ec80970e6bb1c4308724d4366d7519627c98691ab/virtualenv-16.6.0-py2.py3-none-any.whl (2.0MB)
    100% |████████████████████████████████| 2.0MB 14.1MB/s 
Collecting virtualenv-clone (from virtualenvwrapper)
  Downloading https://files.pythonhosted.org/packages/ba/f8/50c2b7dbc99e05fce5e5b9d9a31f37c988c99acd4e8dedd720b7b8d4011d/virtualenv_clone-0.5.3-py2.py3-none-any.whl
Collecting stevedore (from virtualenvwrapper)
  Downloading https://files.pythonhosted.org/packages/c6/dc/6ee92bccfe3c0448786b30b693e6060d62ec8c4a3ec9a287bac1c1a8d8c9/stevedore-1.30.1-py2.py3-none-any.whl (42kB)
    100% |████████████████████████████████| 51kB 28.3MB/s 
Collecting pbr!=2.1.0,>=2.0.0 (from stevedore->virtualenvwrapper)
  Downloading https://files.pythonhosted.org/packages/e0/27/a913b227c9053472ea7dda33e409a1e748e50cdd208a955f3d6a20e9a875/pbr-5.3.0-py2.py3-none-any.whl (108kB)
    100% |████████████████████████████████| 112kB 27.2MB/s 
Collecting six>=1.10.0 (from stevedore->virtualenvwrapper)
  Downloading https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
Installing collected packages: virtualenv, virtualenv-clone, pbr, six, stevedore, virtualenvwrapper
  Running setup.py install for virtualenvwrapper ... done
Successfully installed pbr-5.3.0 six-1.12.0 stevedore-1.30.1 virtualenv-16.6.0 virtualenv-clone-0.5.3 virtualenvwrapper-4.8.4

步骤2

下一步是编辑文件 virtualenvwrapper.sh 。我可以在目录Macintosh HD/Library/Frameworks/Python.framework/Versions/3.7/bin/virtualenvwrapper.sh中找到它。

但是,当我尝试编辑文件 virtualenvwrapper.sh 时,我收到Xcode的警告,指出 virtualenvwrapper.sh当前已锁定,因为您不是该文件的所有者,并且没有拥有写权限。

解决方案

进行一些谷歌搜索,看来我有两种选择:

  1. 使用sudo -H命令进行安装,并永久使用-H。如果是这样,我是否需要卸载我第一次安装的virtualenvwrapper + python3 + pip3?
  2. 以某种方式更改计算机的权限,以便我可以编辑这些文件。我是Mac的唯一用户,所以这不是问题。

推荐的解决方案是什么? 预先感谢您的帮助。

0 个答案:

没有答案