它們之間有什么區別?
/Library/Developer/CommandLineTools/usr/bin/python3
/usr/bin/python3
MacBook-Pro Desktop % whereis python3
/usr/bin/python3
MacBook-Pro Desktop % /usr/bin/python3 --version
Python 3.8.9
MacBook-Pro Desktop % /Library/Developer/CommandLineTools/usr/bin/python3 --version
Python 3.8.9
>python3
Python 3.7.9 (v3.7.9:13c94747c7, Aug 15 2020, 01:31:08)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from my_custom_module.__main__ import main
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'my_custom_module'
但它適用于其他
>/Library/Developer/CommandLineTools/usr/bin/python3
>>>from my_custom_module.__main__ import main
it works
我的意思是,發生了奇怪的事情,當我輸入完整路徑時,我得到 3.8.8,但是當我輸入短名稱“python3”時,我得到 3.7.9。雖然 whereis 回傳如下
MacBook-Pro Desktop % whereis python3
/usr/bin/python3
/usr/bin/python3
Python 3.8.9 (default, Aug 3 2021, 19:21:54)
[Clang 13.0.0 (clang-1300.0.29.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
但
MacBook-Pro Desktop % python3
Python 3.7.9 (v3.7.9:13c94747c7, Aug 15 2020, 01:31:08)
[Clang 6.0 (clang-600.0.57)] on darwin
uj5u.com熱心網友回復:
我認為您的困惑在于whereis命令。 whereis python3實際上并沒有告訴您使用 時將運行什么python3,它只是在標準二進制目錄中搜索指定的程式 ( python3)。我建議which改為使用,因為它會搜索您使用的實際 PATH。
請參閱手冊頁了解 whereis、man page for which、比較。
例如在我的個人電腦上:
? whereis python3
/usr/bin/python3
? which python3
/usr/local/bin/python3
? /usr/bin/python3 --version
Python 3.8.9
? /usr/local/bin/python3 --version
Python 3.9.7
? python3 --version
Python 3.9.7
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/363631.html
下一篇:錯誤“[general]***-[NSKeyedUnarchivervalidateAllowedClass:forKey:]允許取消歸檔...”
