【发布时间】:2016-07-27 01:10:42
【问题描述】:
我想在 python3 (3.5) 中编写程序,因此我在 Mac OS X El Captian 上预安装的 python2 (2.7) 旁边安装了 python3。
由于我的终端默认运行 python2.7 并且已经为它安装了 Numpy,所以我输入了alias python=python3 并希望能够为 python3 安装 Numpy。当我输入pip install numpy。这是生成的消息:
Requirement already satisfied (use --upgrade to upgrade): numpy in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
我还注意到,即使我使用的是 python3,我也没有 pip3:python --version 返回 Python 3.5.2,但 pip3 install numpy 得到了我 -bash: pip3: command not found。
所以我的问题是:
1) python2.x 上安装了 Numpy 时,如何为 python3.x 安装 Numpy?
2) 如何获取 pip3?
3) 使用虚拟环境,例如Conda,而不是在系统上在python2和python3之间玩弄会更好吗?
谢谢你,总共n00b
-------更新-------
在我的情况下,重新安装 python3 还解决了另一个问题。
当我运行brew doctor 时,我收到的警告信息之一是:
Warning: You have unlinked kegs in your Cellar Leaving kegs unlinked can lead to build-trouble and cause brews that depend on those kegs to fail to run properly once built. Run brew link on these: python –
这是我运行brew unlink python 以修复的结果
“Python 意外退出”
当我启动 Vim 时
"ycmd 服务器关闭"
两者似乎都与我为 Python 下载的 YouCompleteMe 自动完成插件有关。
我想从 here 和 here 中删除符号链接
然而,Homebrew 显然不喜欢缺少这 39 个符号链接。
按照 Toby 的建议卸载 (brew uninstall python3) 然后重新安装 python3 (brew install python3) 后,Homebrew 给了我
You can install Python packages with
pip3 install <package>
然后当我pip3 install numpy和pip3 install scipy时,都执行成功了。
令我惊讶的是,在 Python 安装期间创建的符号链接曾经导致 Python 和 YouCompleteMe 出现上述错误消息,但现在我使用 Vim 打开 Python 文件而不会从全新的 Python 安装中崩溃,这肯定会创建符号链接。
------------------ 更新 2 ------------------
重新安装 Anaconda2 后,同样的 YouCompleteMe 错误又回来了。我怀疑 Anaconda 弄乱了符号链接。
【问题讨论】:
标签: python python-2.7 python-3.x pip conda