google-colaboratory - 上下文版本冲突错误,Google colab
问题描述
我正在尝试在 Google colab 上安装和运行 sunpy。它需要 astropy 3.1 或更高版本的软件包。即使在我导入 sunpy 时安装了 astropy 版本 3.2.1 后,它也会出现以下错误:
ContextualVersionConflict Traceback (most recent call last)
<ipython-input-10-1a62dedba559> in <module>()
----> 1 import sunpy
5 frames
/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py in
resolve(self, requirements, env, installer, replace_conflicting,
extras)
789 # Oops, the "best" so far conflicts with a
dependency
790 dependent_req = required_by[req]
--> 791 raise VersionConflict(dist,
req).with_context(dependent_req)
792
793 # push the new requirements onto the stack
ContextualVersionConflict: (astropy 3.0.5
(/usr/local/lib/python3.6/dist-packages),
Requirement.parse('astropy>=3.1'), {'sunpy'})
pip list 给出以下结果:
Package Version
------------------------ ---------------------
absl-py 0.8.0
aioftp 0.13.0
aiohttp 3.6.1
alabaster 0.7.12
albumentations 0.1.12
altair 3.2.0
astor 0.8.0
astropy 3.2.1
如何解决这个问题?
解决方案
astropy >= 3.1
在 sunpy 之前像这样手动安装:
!pip install astropy>=3.1
!pip install sunpy
然后,使用 Runtime -> Restart runtime 菜单重新启动运行时以选择新的 astropy。最后,导入 sunpy。
这是一个工作示例: https ://colab.research.google.com/drive/1741JFtJPq37S8oEzjzvANFWBbH3rQ4Oc
推荐阅读
- reactjs - 当我尝试将 API 调用作为道具从一个组件传递到另一个组件时,承诺未决
- html - 我怎样才能让我的图像环绕我的文字?
- ecmascript-6 - Jasmine 测试依赖项:不能在模块外使用 import 语句
- stackdriver - Opencensus 高级聚合
- python - Python asyncio await-for timeout 不适用于无限任务
- python - QWidget 不接受大于大约 23000 的 setFixedSize 值
- ios - objective-c : 2 个 viewControllers 之间的自定义 segue 转换
- laravel - 使用 Guzzle 客户端获取 API 数据
- angular - Angular 10:下一次调用后订阅 observable 不会触发
- laravel - 尽管获取视图未找到错误,但视图存在