重新安装 Python,但 python 损坏 - 错误的解释器 (Linux Fedora)

发布于 2025-01-15 08:20:25 字数 654 浏览 2 评论 0原文

所以我正在摆弄不同版本的python,以至于现在我什至无法按照建议此处,并且 python 不起作用。 任何命令上出现的错误实际上是:bash:/usr/bin/dnf:/usr/bin/python3:错误的解释器:权限被拒绝

我确实有python3.7、python3.9和/usr/lib 中的 python3.10 文件夹据我所知状况良好。

我能做些什么?

编辑:我当前的 /usr/bin/python3 指向一个目录而不是可执行文件...这可能是问题吗?

which python3 返回以下内容:

/usr/bin/which: no python3 in (/root/.local/bin:/root/bin:/home/dominik/.local/bin:/home/dominik/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/var/lib/snapd/snap/bin)

So I was messing around with different versions of python to the extent that now I cannot even do a dnf reinstall python, as suggested here, and python does not work.
The error which appears on any command really is: bash: /usr/bin/dnf: /usr/bin/python3: bad interpreter: Permission denied

I do have python3.7, python3.9, and python3.10 folders in /usr/lib which as far as I know are in somewhat good condition.

What can I do?

EDIT: my current /usr/bin/python3 points to a directory instead of an executable... could this be the problem?

which python3 returns the following:

/usr/bin/which: no python3 in (/root/.local/bin:/root/bin:/home/dominik/.local/bin:/home/dominik/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/var/lib/snapd/snap/bin)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

内心激荡 2025-01-22 08:20:25

正如评论中所建议的,下载 dnf 配置使用的确切 rpm 包非常重要。这可以通过rpm -qa python3找到。

找到并下载此软件包后,使用 rpm -i 命令安装它。成功安装将创建 /usr/bin/python_version 文件夹。对我来说,它是 python3.10,所以 /usr/bin/python3.10。

完成此操作后,删除 /usr/bin/python3 中现有的符号链接,并链接到新创建的 python 版本。

ln -s /usr/bin/python3.10 /usr/bin/python3

dnf 和 python 现在应该可以工作了。

As suggested in the comments, it is important to download the exact rpm package that dnf is configured to use. This can be found by rpm -qa python3.

After finding and downloading this package, install it using the rpm -i command. A successful installation will create the /usr/bin/python_version folder. For me, it was python3.10, so /usr/bin/python3.10.

When this is done, remove the existing symlink at /usr/bin/python3, and instead link to the newly created python version.

ln -s /usr/bin/python3.10 /usr/bin/python3

dnf and python should now work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文