2017-08-09 60 views
0

我想移動到python3,但是當我從官方網站下載python3時,它似乎安裝在錯誤的地方。該版本安裝在Python3不會安裝在正確的位置

/Library/Frameworks/Python.framework/Versions/ 

而Python(Python的2.3 - 2.7)的所有其他版本至今被安裝在

/System/Library/Frameworks/Python.framework/Versions 

我能夠通過pycharm通過設置訪問蟒蛇3.6解釋解釋器設置爲3.6。但是,當使用其他程序如sublime時,相同的代碼在終端內執行時不起作用,因爲它似乎默認使用python 2.7。另外,我可以通過pycharm訪問的已安裝軟件包在崇高中無法正常工作。執行

import sys 
print(sys.path) 

我得到

['/Users/dominiquepaul/xJob/Youtube Tutorials', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/Library/Python/2.7/site-packages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC'] 

這似乎是證實了它正試圖使用​​舊的蟒蛇,因爲它只是引用的Python 2.7文件夾

我已經嘗試this和其他一些東西,但似乎沒有任何工作

我需要做什麼才能夠在所有程序中默認使用安裝的python3版本?

可能是一個問題,出於同樣的原因文件夾「庫」存在兩次,而不是相同的文件在裏面? 這是因爲:

/library 

以及

/system/library 

作爲新的Python和有點沮喪,因爲我不能讓它跑,我感謝每一個幫助。非常感謝:)

+0

我不認爲這是明智的,覆蓋默認的系統蟒蛇。有libs和其他應用程序使用它。 Python3與Python2不兼容。 – mumbala

回答

0

好的。所以,如果我沒有錯,您希望Python 3成爲您的默認版本,以便它可以在系統中的任何地方使用。 因此,我建議您先卸載您的Python 3. 轉至www.python.org 選擇Python 3版本 下載安裝程序。 從安裝開始。 只要你開始,你會得到一個窗口,你會被要求默認設置路徑。我使用了相同的圖像。 只需選中該複選框即可。 繼續安裝。 完成之後,默認情況下已經爲您的系統設置了Python 3。 現在檢查路徑。 我希望這可以工作。

This is the installation window.You need to select the last check box

0

我不認爲這是明智的,覆蓋默認的系統蟒蛇。有libs和其他應用程序使用它。 Python3與Python2不兼容。

而不是覆蓋默認python提示與python3調用您的腳本。

在你的文件

#!/usr/bin/env python3 

#!/usr/bin/python3 

如果文件是可執行文件(並執行)的最頂端添加標題,那麼系統會選擇python3或指定的版本。

對於崇高的有在包CONFIGS場在這裏你可以設置默認的Python(例如):

"python_interpreter": "/usr/bin/python3",