简体   繁体   English

如何获得python命令来调用python3.7?

[英]How to get the python command to call python3.7?

tl;dr: does anyone know any better way to accomplish basically the same thing as aliases since mine don't work? tl; dr:有人问道,有什么更好的方法可以完成与别名基本相同的事情,因为我的方法不起作用?

hey and thanks for reading, I have a raspberry pi where I'm trying to run a bot that only works on python 3.6 and up. 嘿,感谢您的阅读,我有一个树莓派,我试图在该树中运行一个仅适用于python 3.6及更高版本的机器人。 Python only officially supports up to 3.5 on Raspberry Pi, so I had to manually compile it. Python仅在Raspberry Pi上官方最多支持3.5,因此我不得不手动对其进行编译。 Anyway, the bot I use calls "python3" in its coding, however Raspberry Pis come with 3.5, so calling "python3" actually calls Python 3.5, not 3.7. 无论如何,我使用的bot在其编码中会调用“ python3”,但是Raspberry Pis附带了3.5,因此调用“ python3”实际上是调用Python 3.5,而不是3.7。 I tried deleting Python 3.5, but it then rather than calling Python 3.7, it just said that nothing named python3 exists. 我尝试删除Python 3.5,但是它没有调用Python 3.7,而是说不存在名为python3的内容。 I tried using aliases to call it, but they don't work at all for some reason. 我尝试使用别名来调用它,但是由于某种原因它们根本不起作用。 I know I'm using the right syntax, and I did the update command for the file, but they just don't work. 我知道我使用的语法正确,并且对文件执行了update命令,但是它们根本无法正常工作。 I know that's kind of a lot, but does anyone know any better way to accomplish basically the same thing as aliases since mine don't work? 我知道很多,但是没有人知道什么更好的方法来完成与别名基本相同的事情,因为我的方法不起作用? Or can anyone help me figure out what's wrong with my current coding for aliases? 还是有人可以帮助我弄清楚我当前的别名编码出了什么问题?

Use a full path to your new python version to run it. 使用新python版本的完整路径来运行它。

/full/path/to/3.7/python3.7

What the path is will depend on the directions you followed and options picked when compiling the new python version. 路径将取决于您遵循的方向以及在编译新的python版本时选择的选项。

if you want it to work by simply typing python or python3 you will have to change the symbolic links to point to the new python version. 如果您希望通过简单输入pythonpython3使其工作,则必须更改符号链接以指向新的python版本。

It's not advisable to install an out-of-distribution Python version, and you can't expect system libraries to work with it. 不建议安装发行外的Python版本,并且您不能指望系统库可以使用它。

Your best bet is to upgrade to Raspbian Buster, as it comes with Python 3.7 as standard. 最好的选择是升级到Raspbian Buster,因为它是Python 3.7的标准配置。 Buster is still in testing phase and not due for release until the summer, but I've been using it for a while and it seems to work ok. Buster仍处于测试阶段,要等到夏天才能发布,但是我已经使用了一段时间,而且看起来还可以。 I have had success upgrading the Lite image but not Desktop. 我已经成功升级了Lite映像,但没有升级桌面。

To upgrade, edit /etc/apt/sources.list and replace stretch with buster , then run apt update; apt dist-upgrade 要进行升级,请编辑/etc/apt/sources.list并将stretch替换为buster ,然后运行apt update; apt dist-upgrade buster apt update; apt dist-upgrade and wait for it to do the upgrade, then reboot and you'll have python3 pointing at Python 3.7. apt update; apt dist-upgrade并等待它进行升级,然后重新启动,您将拥有python3指向Python 3.7。

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

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