问题描述
我遇到了一个我无法解决的错误,尽管其他人报告了同样的错误.
I'm running into an error that I can't solve despite others having reported the same error.
我正在远程连接到 Linux 机器.我已经安装了最新版本的 anaconda:
I am connecting remotely to a Linux machine. I have installed the latest version of anaconda:
我更新了对应的路径,好像可以了:
I updated the corresponding paths and it seems like it works:
太好了,所以现在我想使用 Anaconda 预装的 conda
.看起来 Anaconda 给了我 3.18.3:
Great, so now I want to use conda
, which is pre-installed with Anaconda. It looks like Anaconda gave me 3.18.3:
按照试驾说明,我更新了conda:
Following the test drive instructions, I update conda:
很遗憾,我不知道如何避免这个错误.
Unfortunately, I can't figure out how to avoid this error.
我发现了一些其他 StackOverflow 帖子.这个建议从头开始重新安装python和pycharm(但我刚刚安装了Anaconda,我不使用pycharm).另一个建议重新安装机盖,但我'我不在这里使用它.最后,第三个建议这实际上是一个错误,并提出了修复建议.不幸的是,重命名 sys.version
无法解决错误.这甚至不是我的电脑,所以我不想深入研究代码并冒险搞砸.
I found a few other StackOverflow posts. This one suggests reinstalling python and pycharm from scratch (but I just installed Anaconda and I don't use pycharm). Another suggests reinstalling canopy, but I'm not using that here. Finally, a third suggests that it's actually a bug, and proposes a fix. Unfortunately, re-naming sys.version
fails to resolve the error. This isn't even my computer so I don't want to get deep into the code and risk messing something up.
我会很感激一些想法或建议.
I would appreciate some thoughts or advice.
推荐答案
第三种解决方案是正确的.这确实是一个错误,因为修改后的 sys.version
字符串破坏了许多依赖于具有特定格式的字符串的 platform
模块函数.
Third solution is correct. This is indeed a bug, since modified sys.version
string breaks a number of platform
module functions that rely on that string having certain format.
但是,如果您无法正确修复它,您可以尝试一个 hacky 解决方法.模块 platform
实际上有一个用于解析 sys.version
字符串的缓存:所以你要做的是:
However, if you cannot fix it properly, you can attempt a hacky workaround. Module platform
actually has a cache for parsing sys.version
string: so what you have to do is:
- 备份 Anaconda 修改的 sys.version.
- 将其替换为合法版本字符串.
- 调用任何能够解析 sys.version 字符串的
platform
模块函数. - 为 Anaconda 修改的 sys.version 复制它的缓存.
- 从备份中恢复 sys.version.
破解自己:
您需要将此代码放在将要执行的位置在 conda 有机会因异常而失败.不确定最好的地方是什么,但您可以尝试使用 conda/cli/main.py
、conda/api.py
或 conda/connection.py
.
You need to put this code somewhere where it will be executed before conda has a chance to fail with exception. Not sure what the best place would be, but you could try it with conda/cli/main.py
, conda/api.py
or conda/connection.py
.
这篇关于ValueError:使用 conda 命令后无法解析 CPython sys.version的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!