浏览器:Google Chrome 最新版
我关注了这个Conda + Google Colab在 colab 中设置 conda 的文章几天前运行良好。
之后,我尝试设置FairMOT 通过运行这些命令
!conda create -n FairMOT --yes
!conda activate FairMOT --yes
!conda install pytorch==1.2.0 torchvision==0.4.0 cudatoolkit=10.0 -c pytorch --yes
现在,这是我收到的错误输出。
CommandNotFoundError: Your shell has not been properly configured to use 'conda deactivate'.
To initialize your shell, run
$ conda init <SHELL_NAME>
Currently supported shells are:
- bash
- fish
- tcsh
- xonsh
- zsh
- powershell
See 'conda init --help' for more information and options.
IMPORTANT: You may need to close and restart your shell after running 'conda init'.
Collecting package metadata (current_repodata.json): failed
InvalidVersionSpec: Invalid version '4.19.112+': empty version component
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
To initialize your shell, run
$ conda init <SHELL_NAME>
Currently supported shells are:
- bash
- fish
- tcsh
- xonsh
- zsh
- powershell
See 'conda init --help' for more information and options.
IMPORTANT: You may need to close and restart your shell after running 'conda init'.
Collecting package metadata (current_repodata.json): failed
InvalidVersionSpec: Invalid version '4.19.112+': empty version component
最佳答案
我创建了一个有效的快速修复方法。我不推荐将此作为长期解决方案。
更改引发 InvalidVersionSpec
错误的文件内容。就我而言,这是文件 /usr/local/lib/python3.7/site-packages/conda/models/version.py。您可以使用 !conda create your_env --verbose
获取该文件的位置。 (请注意,一个文件生成异常,但另一个文件引发 InvalidVersionSpec
,选择后者)。
以下是我们感兴趣的代码行:
# imports...
# Class definitions...
@with_metaclass(SingleStrArgCachingType)
class VersionOrder(object):
# ...
def __init__(self, vstr):
# ...
# The following line is raising the Exception:
if not c:
raise InvalidVersionSpec(vstr, "empty version component")
在 VersionOrder
类的 __init__
方法的第一行添加以下内容:
if isinstance(vstr, str) and vstr == '4.19.112+':
vstr = '4.19.112'
所以它看起来像这样:
# imports...
# Class definitions...
@with_metaclass(SingleStrArgCachingType)
class VersionOrder(object):
# ...
def __init__(self, vstr):
if isinstance(vstr, str) and vstr == '4.19.112+': # Added code
vstr = '4.19.112'
# ...
# The following line is raising the Exception:
if not c:
raise InvalidVersionSpec(vstr, "empty version component")
所发生的事情基本上是从版本名称中删除+
。它会产生错误,因此可能是版本规范的拼写错误,或者是 conda 的 VersionOrder 类处理此语法时的错误。我建议将此解决方案作为快速修复,以避免对两个文件产生副作用。
如何在 Colab 中轻松完成此操作
使用 cat 打印文件 /usr/local/lib/python3.7/site-packages/conda/models/version.py 的内容:
!cat /usr/local/lib/python3.7/site-packages/conda/models/version.py
使用剪贴板复制内容并将其粘贴到以魔术命令 %%file my_new_version_file.py
:
%%file my_new_version_file.py
# Paste your clipboard here
接下来,在这个新单元中添加前面提到的代码并运行它。 这将创建一个包含单元格内容的文件 my_new_version_file.py。
然后使用shutil
将生成的文件移动到原始文件的路径中:
import shutil
shutil.move('my_new_version_file.py', '/usr/local/lib/python3.7/site-packages/conda/models/version.py')
关于deep-learning - Conda Colab 收集包元数据时出错 (current_repodata.json) : failed InvalidVersionSpec: Invalid version '4.19.112+' :empty version component,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66956203/