在OSX 10.11.1上使用pip安装virtualenv virtualenvwrapper [英] Installing virtualenv virtualenvwrapper with pip on osx 10.11.1

查看:84
本文介绍了在OSX 10.11.1上使用pip安装virtualenv virtualenvwrapper的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

安装virtualenv virtualenvwrapper

Install virtualenv virtualenvwrapper

我正在尝试按照本教程 https://realpython.com/blog/python/flask-by-example-part-1-project-setup/

I am trying to create a sample flask app by following this tutorial https://realpython.com/blog/python/flask-by-example-part-1-project-setup/

但是自从我在运行于10.11.1的新Mac上设置Python和相关技术以来,我一直遇到一些问题.

But I am running into constant issues since I am setting up Python and related technologies on this new Mac running on 10.11.1

我被卡在输入此命令的地方

I am stuck at the command where I enter this

$ mkvirtualenv --python =/usr/local/bin/python3字数统计

$ mkvirtualenv --python=/usr/local/bin/python3 wordcounts

我后来意识到我没有python3.但是仍然有

I later realized that I did not have python 3. But still i have the error of

-bash: mkvirtualenv: command not found

因此,我找到了本教程来帮助安装virtualenv 在Mac OS X上安装virtualenv和virtualenvwrapper ,并说可以运行

So i found this tutorial to help install virtualenv Install virtualenv and virtualenvwrapper on Mac OS X and it said to run this

pip install virtualenv virtualenvwrapper

但是后来我遇到了点子问题

But then i ran into problem with pip

我认为我已经在找到了答案在OSX 10.11 El Capitan上安装virtualenvwrapper

回答

sudo pip install pbr
sudo pip install --no-deps stevedore
sudo pip install --no-deps virtualenvwrapper

但是,甚至另一个用户在接受的答案的注释中提到它不适用于 10.11.1

but even another user mentioned in the comments of the accepted answer that it was not working on 10.11.1

Captains-MacBook-Pro:flask-by-example mac$ sudo pip install pbr
Password:
The directory '/Users/mac/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/mac/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.
Requirement already satisfied (use --upgrade to upgrade): pbr in /Library/Python/2.7/site-packages
Captains-MacBook-Pro:flask-by-example mac$ sudo pip install --no-deps stevedore
The directory '/Users/mac/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/mac/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 stevedore
  Downloading stevedore-1.9.0-py2.py3-none-any.whl
Installing collected packages: stevedore
Successfully installed stevedore-1.9.0
Captains-MacBook-Pro:flask-by-example mac$ sudo pip install --no-deps virtualenvwrapper
The directory '/Users/mac/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/mac/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 virtualenvwrapper-4.7.1-py2.py3-none-any.whl
Installing collected packages: virtualenvwrapper
Successfully installed virtualenvwrapper-4.7.1
Captains-MacBook-Pro:flask-by-example mac$ sudo pip install virtualenv virtualenvwrapper
The directory '/Users/mac/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/mac/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.
Requirement already satisfied (use --upgrade to upgrade): virtualenv in /Library/Python/2.7/site-packages
Requirement already satisfied (use --upgrade to upgrade): virtualenvwrapper in /Library/Python/2.7/site-packages
Requirement already satisfied (use --upgrade to upgrade): virtualenv-clone in /Library/Python/2.7/site-packages (from virtualenvwrapper)
Requirement already satisfied (use --upgrade to upgrade): stevedore in /Library/Python/2.7/site-packages (from virtualenvwrapper)
Requirement already satisfied (use --upgrade to upgrade): pbr>=1.6 in /Library/Python/2.7/site-packages (from stevedore->virtualenvwrapper)
Requirement already satisfied (use --upgrade to upgrade): argparse in /Library/Python/2.7/site-packages (from stevedore->virtualenvwrapper)
Collecting six>=1.9.0 (from stevedore->virtualenvwrapper)
  Downloading six-1.10.0-py2.py3-none-any.whl
Installing collected packages: six
  Found existing installation: six 1.4.1
    DEPRECATION: Uninstalling a distutils installed project (six) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
    Uninstalling six-1.4.1:
Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/basecommand.py", line 211, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/commands/install.py", line 311, in run
    root=options.root_path,
  File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/req/req_set.py", line 640, in install
    requirement.uninstall(auto_confirm=True)
  File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/req/req_install.py", line 716, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/req/req_uninstall.py", line 125, in remove
    renames(path, new_path)
  File "/Library/Python/2.7/site-packages/pip-7.1.2-py2.7.egg/pip/utils/__init__.py", line 315, in renames
    shutil.move(old, new)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in move
    copy2(src, real_dst)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 131, in copy2
    copystat(src, dst)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 103, in copystat
    os.chflags(dst, st.st_flags)
OSError: [Errno 1] Operation not permitted: '/tmp/pip-tK4FXO-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'
Captains-MacBook-Pro:flask-by-example mac$

推荐答案

您不应该使用系统版本的Python.

You shouldn't be using your system's version of Python.

根据 Python的文档:

OS X随附的Python版本非常适合学习,但不利于开发.

The version of Python that ships with OS X is great for learning but it’s not good for development.

根据 Apple的文档:

鼓励使用Perl,Python,Ruby或OS X附带的任何其他脚本语言的开发人员管理他们自己的语言和依赖项安装...

Developers using Perl, Python, Ruby, or any other scripting languages that ship with OS X, are encouraged to manage their own installations of the language and dependencies ...

因此,我建议按照 Python的OS X安装文档.

请注意,这些说明提供了安装Python 2的命令.要安装Python 3,请运行:

Note that these instructions provide the command to install Python 2. To install Python 3, you would run:

brew install python3    # instead of 'brew install python'

这些Python安装文档还链接到安装virtualenv的详细说明,并virtualenvwrapper .

These Python installation docs also link to detailed instructions for installing virtualenv and virtualenvwrapper.

更新:

看起来您已安装virtualenvwrapper,但配置不正确.安装后,我根据 virtualenvwrapper 的安装文档运行了以下代码,以进行配置:

It looks like you have virtualenvwrapper installed, but not properly configured. When I installed it, I ran the following code based on installation docs for virtualenvwrapper to configure:

# Create a directory to hold the virtual environments.
mkdir $HOME/.virtualenvs

echo "
# Python's virtualenvwrapper-RELATED
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh 
" >> ~/.bash_profile
source ~/.bash_profile

这篇关于在OSX 10.11.1上使用pip安装virtualenv virtualenvwrapper的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆