求教关于在 osx 下安装 python3 的一个问题

2016 年 4 月 16 日
 soratadori

几乎没怎么用过 osx ,装个 python 就出问题了。

按照网上的教程设置好后,输入 python ,可以正常运行 python3 了
Python 3.5.1 (v3.5.1:37a07cee5969, Dec 5 2015, 21:12:44) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information.

但是好像还是有问题,像输入 pydoc 或者打开 pip3 都会显示下面的错误
-bash: /usr/bin/pydoc: /Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5: bad interpreter: No such file or directory

因为把 /Library/.../python3.5 移动到 /System/Library/.../python3.5 下面去了,所以出现错误很正常.
我猜这个应该是环境变量的问题吧,是设置这个用户目录下的.bash_profile 这个文件(~/.bash_profile)吗,但把下面内容写进去也似乎没用

# Setting PATH for Python 3.5
# The orginal version is saved in .bash_profile.pysave
PATH="/System/Library/Frameworks/Python.framework/Versions/3.5/bin:${PATH}"
export PATH

头两行是注视吧,有啥意义,这个.bash_profile.pysave 的文件好像也没见啊?

4270 次点击
所在节点    Python
15 条回复
cheerzeng
2016 年 4 月 16 日
我刚开始用 mac 的时候也是直接就装 python ,但这样好像容易把 mac 本身的 python 弄乱,所以建议先安装 virtualenv ,再在里面安装所需版本的 python
pimin
2016 年 4 月 16 日
/t/269405
供参考
LINAICAI
2016 年 4 月 16 日
不要随便动 Python ,苹果系统对他有版本依赖,用 brew 安装其他版本啊
noli
2016 年 4 月 16 日
@LINAICAI 说的是最 easy 的正道。

你看的什么鬼教程…… 帖出来让大家鞭挞吧
congeec
2016 年 4 月 16 日
为什么这样装 python ?
brew install python3 不行么?
leavic
2016 年 4 月 16 日
用 homebrew 最安全, 2.7 版的就不要去动了。
mornlight
2016 年 4 月 16 日
Why not pyenv ?
soratadori
2016 年 4 月 16 日
→_→我照你们说的去试试好了
franklinyu
2016 年 4 月 16 日
搞系統 Python 的一看就沒有潔癖
skydiver
2016 年 4 月 17 日
因为你那个程序里写死了 python 路径吧。手动编辑一下就行了。或者删掉重新装 pip 包,让路径都是新的
Ixizi
2016 年 4 月 17 日
virtualenv
ykqmain
2016 年 4 月 17 日
我觉得没必要将 python 设为默认,很容易乱。
要用 python3 就多输入的一个数字, python3 XXX.py , pip3 XXX 什么的,也不是很麻烦
wzqcongcong
2016 年 4 月 17 日
pyenv~
2zH
2016 年 4 月 17 日
brew install python3 就可以了
fatea
2016 年 5 月 8 日
pyenv 是最实用的,多版本管理 /虚拟环境都很好。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/271582

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX