I'm trying to import gluonts in a Jupyter Notebook, so I installed the module through:
!pip install gluonts
Then I try to import a class from the module:
from gluonts.trainer import Trainer
But I get this exception:
ContextualVersionConflict Traceback (most recent call last)
<ipython-input-3-d4623db96f76> in <module>()
----> 1 from gluonts.trainer import Trainer
2 from gluonts.dataset.common import ListDataset
3 from gluonts.model.deepar import DeepAREstimator
~/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/gluonts/__init__.py in <module>()
21
22 try:
---> 23 __version__ = get_distribution(__name__).version
24 except DistributionNotFound:
25 __version__ = "0.0.0-unknown"
...
~/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages/pkg_resources/__init__.py in resolve(self, requirements, env, installer, replace_conflicting, extras)
781 # Oops, the "best" so far conflicts with a dependency
782 dependent_req = required_by[req]
--> 783 raise VersionConflict(dist, req).with_context(dependent_req)
784
785 # push the new requirements onto the stack
ContextualVersionConflict: (pandas 0.24.2 (/home/ec2-user/anaconda3/envs/mxnet_p36/lib/python3.6/site-packages), Requirement.parse('pandas~=1.0'), {'gluonts'})
The problem is that it wants to have a newer version of pandas so I did this:
!pip install -Iv pandas==1.0.5
But, checking the version with:
import pandas as pd
print(pd.__version__)
The printed one is not 1.0.5, but 0.24.2. Do you have any ideas on how to force the correct installation or to avoid this issue? Thanks in advance.
The problem you have is that you uninstalled pandas after its importation, so the notebook kept the old version, even if you imported the newly installed module. To solve the problem you have to restart your notebook, after deletion of the old pandas and the installation of the new version. Another way to permanently solve this issue is, just after the notebook startup, to uninstall and to update pandas before every importation. I figured this out after reading comments and trying what they said.