无法在Python版本之间切换

时间:2016-11-15 18:10:50

标签: python macos terminal

我在Python版本之间切换有困难,因为3.5不是我预期的那样,我不知道如何使用它。我知道它在那里,但我找不到它或访问它。请帮我理解发生了什么。我正在运行Mac OSX 10.12.1

$ which -a python
/usr/bin/python
$ python -V
Python 2.7.10
$ usr/bin/python3.5.2
no such file or directory: usr/bin/python3.5.2
$ /Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 26 2016, 10:47:25)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> ^D
$ python -V
Python 2.7.10
$ ls -ls /usr/bin/python*
32 -rwxr-xr-x  1 root  wheel  66848 Sep 13 18:56 /usr/bin/python
 0 -rwxr-xr-x  5 root  wheel    925 Jul 30 19:36 /usr/bin/python-config
 8 lrwxr-xr-x  1 root  wheel     75 Oct  8 12:56 /usr/bin/python2.6 -> ../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6
 8 lrwxr-xr-x  1 root  wheel     82 Oct  8 12:56 /usr/bin/python2.6-config -> ../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6-config
 8 lrwxr-xr-x  1 root  wheel     75 Oct  8 12:56 /usr/bin/python2.7 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
 8 lrwxr-xr-x  1 root  wheel     82 Oct  8 12:56 /usr/bin/python2.7-config -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-config
32 -rwxr-xr-x  1 root  wheel  66848 Sep 13 18:57 /usr/bin/pythonw
 8 lrwxr-xr-x  1 root  wheel     76 Oct  8 12:56 /usr/bin/pythonw2.6 -> ../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/pythonw2.6
 8 lrwxr-xr-x  1 root  wheel     76 Oct  8 12:56 /usr/bin/pythonw2.7 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw2.7

我知道3.5在我的系统上的唯一方法是因为我一直在Pycharm中使用它(这是我找到/Library/Frameworks/../python3.5路径的地方)

我重新安装了Python 3.5,但它没有改变位置。

我真正想做的是在终端中使用Python 3.5作为默认值,但我也决定能够使用virtualenv设置3.5。 (我的几乎所有程序都运行在3.5:这个问题是新的,因为我从终端切换到iTerm和ZSH)

我可以通过指定路径启动虚拟环境,但问题是1.为什么3.5安装在其他地方,以及2.为什么我不能从命令行找到它?

$ virtualenv -p /Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5 venv
Running virtualenv with interpreter 
Installing setuptools, pip, wheel...done.
$ source venv/bin/activate
(venv) $ python -V
Python 3.5.2

0 个答案:

没有答案