gpt4 book ai didi

python - 在 osx 10.11.1 上使用 pip 安装 virtualenv virtualenvwrapper

转载 作者:太空狗 更新时间:2023-10-30 02:18:53 25 4
gpt4 key购买 nike

目标

安装virtualenv virtualenvwrapper

背景

我正在尝试按照本教程 https://realpython.com/blog/python/flask-by-example-part-1-project-setup/ 创建一个示例 Flask 应用程序

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

我卡在输入这个的命令上了

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

后来我意识到我没有python 3。但是我仍然有错误

-bash: mkvirtualenv: command not found

所以我找到了这个教程来帮助安装 virtualenv Install virtualenv and virtualenvwrapper on Mac OS X它说要运行这个

pip install virtualenv virtualenvwrapper

但是后来我遇到了 pip 的问题

当前状态

我以为我在 Can't install virtualenvwrapper on OSX 10.11 El Capitan 找到了现有答案

回答说

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

但甚至另一位用户在已接受答案的评论中提到它不适用于 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 版本。

根据 Python's docs :

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

根据 Apple's docs :

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's OS X installation docs 中的建议和描述使用自制软件安装 Python 2 和/或 Python 3。 .

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

brew install python3    # instead of 'brew install python'

这些 Python 安装文档还链接到关于 installing virtualenv and virtualenvwrapper 的详细说明。 .

更新:

您似乎安装了 virtualenvwrapper,但未正确配置。当我安装它时,我根据 installation docs for virtualenvwrapper 运行了以下代码配置:

# 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

关于python - 在 osx 10.11.1 上使用 pip 安装 virtualenv virtualenvwrapper,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33658888/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com