Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Contextual version conflict error, Google colab

I am trying to install and run sunpy on Google colab. It requires a package astropy version 3.1 or higher. Even after installing astropy version 3.2.1 when I import sunpy it gives the following error:

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 gives the following result:

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 

How this can be resoloved?

like image 579
Partha S. Pal Avatar asked Jul 17 '26 11:07

Partha S. Pal


1 Answers

Install astropy >= 3.1 by hand like so before sunpy:

!pip install astropy>=3.1
!pip install sunpy

Then, restart your runtime to pick up the new astropy using the Runtime -> Restart runtime menu. Finally, import sunpy.

Here's a worked example: https://colab.research.google.com/drive/1741JFtJPq37S8oEzjzvANFWBbH3rQ4Oc

enter image description here

like image 116
Bob Smith Avatar answered Jul 25 '26 21:07

Bob Smith



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!