Mac 中同时有三个版本的 Python , 2.7、3.5 和 3.6,但是 terminal 中无法使用 3.5,而 Pycharm 却可以,请问这是为什么?

2017-05-05 07:52:50 +08:00
 Ferrix
4162 次点击
所在节点    Python
18 条回复
kindjeff
2017-05-05 07:58:29 +08:00
不能用是什么意思,你敲 python3.5 回车没反应,还是切到 python3.5 的目录运行不了?
zsz
2017-05-05 08:03:55 +08:00
终端下切到 python3.5 安装位置,手动运行下看看


加我们的群问效率更高,一群工程师组建的面向初学者的
Python Linux 学习群,qq 群号:278529278,
Php Linux 学习群,qq 群号:476648701,
非商业性质,拒绝广告,只接收真正想学这方面技术的朋友,交流学习,申请请说明来自 v2ex
zhaojjxvi
2017-05-05 08:04:43 +08:00
Pycharm 也不自带 Python3 啊,应该是你给配的环境变量啊什么的用的 3.5
KeepPro
2017-05-05 08:08:45 +08:00
ide 配置的绝对路径,终端里面你也用全路径就行
arischow
2017-05-05 08:18:33 +08:00
pyenv
Tink
2017-05-05 08:38:07 +08:00
环境变量的问题吧
LokiSharp
2017-05-05 08:58:11 +08:00
cd bin
mv python python.bak
ln -s pythonXY python

在 bin 里面的 python* 全都是以软连接的形式存在的 想要改 python 版本自己重建软连接就行了。
zhengxiaowai
2017-05-05 10:36:32 +08:00
环境变量问题
richardma
2017-05-05 20:34:55 +08:00
为何不用 virtualenv ?
Ferrix
2017-05-06 08:07:05 +08:00
@kindjef

~ python3.5
zsh: command not found: python3.5
Ferrix
2017-05-06 08:08:32 +08:00
@zhaojjxvi 恩,PyCharm 可以选择 project interpreter,因为之前很多包都装在了 3.5 中
Ferrix
2017-05-06 08:09:25 +08:00
@KeepPro 恩,我试试
Ferrix
2017-05-06 08:16:10 +08:00
@arischow 谢谢
Ferrix
2017-05-06 08:17:35 +08:00
昨天有事没用电脑,多谢各位的热心解答
LokiSharp
2017-05-06 09:28:22 +08:00
@Ferrix 应该是 python35 不带点的,你去 /bin 看看就知道了
LokiSharp
2017-05-06 09:31:40 +08:00
@LokiSharp 不对。。。是带点的。。。
LokiSharp
2017-05-06 09:34:58 +08:00
$ ll python*
lrwxrwxrwx 1 root root 7 Jan 17 21:24 python -> python2
lrwxrwxrwx 1 root root 9 Jan 17 21:24 python2 -> python2.7
-rwxr-xr-x 1 root root 7136 Nov 6 08:29 python2.7
-rwxr-xr-x 1 root root 1835 Nov 6 08:29 python2.7-config
-rwxr-xr-x 1 root root 304 Dec 13 19:49 python2.7-futurize
-rwxr-xr-x 1 root root 308 Dec 13 19:49 python2.7-pasteurize
lrwxrwxrwx 1 root root 16 Jan 17 23:28 python2-config -> python2.7-config
-rwxr-xr-x 1 root root 11312 Dec 29 09:58 python3
-rwxr-xr-x 2 root root 11312 Nov 10 00:27 python3.4
-rwxr-xr-x 2 root root 11312 Nov 10 00:27 python3.4m
-rwxr-xr-x 2 root root 11312 Apr 7 22:35 python3.6
-rwxr-xr-x 2 root root 11312 Apr 7 22:35 python3.6m
lrwxrwxrwx 1 root root 9 Jan 17 23:31 python3.bak -> python3.4
lrwxrwxrwx 1 root root 14 Jan 17 23:28 python-config -> python2-config
xray887
2017-05-23 09:53:06 +08:00
➜ /Users/xray887 >which python
/usr/local/bin/python
➜ /Users/xray887 >cd /usr/local/bin
➜ /usr/local/bin >ll python*
lrwxr-xr-x 1 xray887 admin 34B 12 28 20:45 python -> ../Cellar/python/2.7.13/bin/python
lrwxr-xr-x 1 xray887 wheel 71B 11 26 2015 python-32 -> ../../../Library/Frameworks/Python.framework/Versions/2.7/bin/python-32
lrwxr-xr-x 1 xray887 admin 41B 12 28 20:45 python-config -> ../Cellar/python/2.7.13/bin/python-config
lrwxr-xr-x 1 xray887 admin 35B 12 28 20:45 python2 -> ../Cellar/python/2.7.13/bin/python2
lrwxr-xr-x 1 xray887 wheel 72B 11 26 2015 python2-32 -> ../../../Library/Frameworks/Python.framework/Versions/2.7/bin/python2-32
lrwxr-xr-x 1 xray887 admin 42B 12 28 20:45 python2-config -> ../Cellar/python/2.7.13/bin/python2-config
lrwxr-xr-x 1 xray887 admin 37B 12 28 20:45 python2.7 -> ../Cellar/python/2.7.13/bin/python2.7
lrwxr-xr-x 1 xray887 wheel 74B 11 26 2015 python2.7-32 -> ../../../Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-32
lrwxr-xr-x 1 xray887 admin 44B 12 28 20:45 python2.7-config -> ../Cellar/python/2.7.13/bin/python2.7-config
lrwxr-xr-x 1 xray887 admin 35B 4 28 10:06 python3 -> ../Cellar/python3/3.6.1/bin/python3
lrwxr-xr-x 1 xray887 wheel 72B 11 13 2015 python3-32 -> ../../../Library/Frameworks/Python.framework/Versions/3.5/bin/python3-32
lrwxr-xr-x 1 xray887 admin 42B 4 28 10:06 python3-config -> ../Cellar/python3/3.6.1/bin/python3-config
lrwxr-xr-x 1 xray887 wheel 74B 11 13 2015 python3.5-32 -> ../../../Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5-32
lrwxr-xr-x 1 xray887 admin 37B 4 28 10:06 python3.6 -> ../Cellar/python3/3.6.1/bin/python3.6
lrwxr-xr-x 1 xray887 admin 44B 4 28 10:06 python3.6-config -> ../Cellar/python3/3.6.1/bin/python3.6-config
lrwxr-xr-x 1 xray887 admin 38B 4 28 10:06 python3.6m -> ../Cellar/python3/3.6.1/bin/python3.6m
lrwxr-xr-x 1 xray887 admin 45B 4 28 10:06 python3.6m-config -> ../Cellar/python3/3.6.1/bin/python3.6m-config
lrwxr-xr-x 1 xray887 admin 35B 12 28 20:45 pythonw -> ../Cellar/python/2.7.13/bin/pythonw
lrwxr-xr-x 1 xray887 wheel 72B 11 26 2015 pythonw-32 -> ../../../Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw-32
lrwxr-xr-x 1 xray887 admin 36B 12 28 20:45 pythonw2 -> ../Cellar/python/2.7.13/bin/pythonw2
lrwxr-xr-x 1 xray887 wheel 73B 11 26 2015 pythonw2-32 -> ../../../Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw2-32
lrwxr-xr-x 1 xray887 admin 38B 12 28 20:45 pythonw2.7 -> ../Cellar/python/2.7.13/bin/pythonw2.7
lrwxr-xr-x 1 xray887 wheel 75B 11 26 2015 pythonw2.7-32 -> ../../../Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw2.7-32

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

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

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

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

© 2021 V2EX