简体   繁体   English

IDLE 在 mac 上使用与 python3 不同的 python 版本

[英]IDLE uses a different python version than python3 on mac

I develop on Mac OSX (version 11.2.3) with python, using IDLE.我使用 IDLE 在带有 python 的 Mac OSX(版本 11.2.3)上开发。

When I run IDLE, it uses python version 3.8.1, which has been installed in /usr/local/bin .当我运行 IDLE 时,它使用 python 版本 3.8.1,它已安装在/usr/local/bin中。 For some reason I cannot run python3.8 via the command line from /usr/local/bin - it just returns 'file not found' or 'command not found'.出于某种原因,我无法通过/usr/local/bin的命令行运行 python3.8 - 它只返回“找不到文件”或“找不到命令”。 I've tried running python3.8 or ./python3.8 or /usr/local/bin/python3.8 and they all come up with errors, even though I can see the file in there.我试过运行python3.8./python3.8/usr/local/bin/python3.8并且它们都出现错误,即使我可以在那里看到文件。

When I use python via the command line, it uses python version 3.8.2 which has been installed in usr/bin .当我通过命令行使用 python 时,它使用 python 版本 3.8.2 已安装在usr/bin中。 There's python2.7 in there as well, and I can run python2.7 by typing 'python2.7' just fine.里面也有python2.7,我可以通过输入'python2.7'来运行python2.7。 the command python runs python2.7 and the command python3 runs python 3.8.2.命令python运行 python2.7,命令python3运行 python 3.8.2。

Running python jobs via the crontab causes errors with scripts I have written using IDLE.通过 crontab 运行 python 作业会导致我使用 IDLE 编写的脚本出错。 These seem mainly to do with libraries.这些似乎主要与图书馆有关。 IDLE looks for libraries in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/ while python3 looks for them in /Library/Python/3.8/site-packages . IDLE 在/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/ /Library/Python/3.8/site-packages查找它们。 When I install a package via pip3 it installs them in /Library/Python/3.8/site-packages and then I have to move them to /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/ to get them to work in IDLE.当我通过pip3安装 package 时,它会将它们安装在/Library/Python/3.8/site-packages中,然后我必须将它们移动到/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/让它们在 IDLE 中工作。

I start IDLE as idle3 from /usr/bin and it uses python3.8.1.我从/usr/bin以idle3 启动IDLE,它使用python3.8.1。

How do I get IDLE to use python3.8.2 so it uses the same python as the 'python3' command?如何让 IDLE 使用python3.8.2 ,使其使用与“python3”命令相同的 python?

In fact IDLE is no more than a Python module from the standard library.事实上,IDLE 只不过是标准库中的一个 Python 模块。 So if you have a command that starts a specific Python version (let us call it python3.x ) then you can start an IDLE using that version with:因此,如果您有一个启动特定 Python 版本的命令(让我们称之为python3.x ),那么您可以使用该版本启动 IDLE:

python3.x -m idlelib

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM