Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ModuleNotFoundError: No module named 'mxnet'

Tags:

python

I have been looking for the solution for this error for a whole morning. I created an separate environment for python 3.6 and I still got this error. I am using anacondas. So i am so frustrated.

ModuleNotFoundError: No module named 'mxnet'


from gluonts.model.deepar import DeepAREstimator
from gluonts.trainer import Trainer
import mxnet as mx
import numpy as np

np.random.seed(7)
mx.random.seed(7)

estimator = DeepAREstimator(
    prediction_length=28,
    context_length=100,
    freq='H',
    trainer=Trainer(ctx="gpu", # remove if running on windows
                    epochs=5,
                    learning_rate=1e-3,
                    num_batches_per_epoch=100
                   )
)

predictor = estimator.train(train_ds)

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-14-d803033f31d5> in <module>
----> 1 from gluonts.model.deepar import DeepAREstimator
      2 from gluonts.trainer import Trainer
      3 import mxnet as mx
      4 import numpy as np
      5 

~\miniconda3\envs\deepar\lib\site-packages\gluonts\model\deepar\__init__.py in <module>
     12 # permissions and limitations under the License.
     13 
---> 14 from ._estimator import DeepAREstimator
     15 
     16 __all__ = ["DeepAREstimator"]

~\miniconda3\envs\deepar\lib\site-packages\gluonts\model\deepar\_estimator.py in <module>
     16 
     17 import numpy as np
---> 18 from mxnet.gluon import HybridBlock
     19 
     20 from gluonts.core.component import DType, validated

ModuleNotFoundError: No module named 'mxnet'

I installed both gluonts successfully. then I tried to install mxnet by conda install mxnet, there are so many conflicts, not sure why, here are just part of conflicts. Thanks for your help

Package notebook conflicts for:
widgetsnbextension -> notebook[version='>=4.4.1']
jupyter -> notebook
ipywidgets -> widgetsnbextension[version='>=3.5.0,<3.6.0'] -> notebook[version='>=4.4.1']

Package matplotlib-base conflicts for:
matplotlib -> matplotlib-base[version='3.1.2|3.1.2|3.1.2|3.1.3|3.1.3|3.1.3|>=3.2.1,<3.2.2.0a0|>=3.2.2,<3.2.3.0a0|>=3.3.1,<3.3.2.0a0|>=3.4.3,<3.4.4.0a0|>=3.4.2,<3.4.3.0a0|>=3.3.4,<3.3.5.0a0|>=3.3.2,<3.3.3.0a0',build='py36h64f37c6_1|py36h64f37c6_0|py37h64f37c6_0|py38h64f37c6_0|py37h64f37c6_1|py38h64f37c6_1']
gluonts -> matplotlib~=3.0 -> matplotlib-base[version='3.1.2|3.1.2|3.1.2|3.1.3|3.1.3|3.1.3|>=3.2.1,<3.2.2.0a0|>=3.2.2,<3.2.3.0a0|>=3.3.1,<3.3.2.0a0|>=3.4.3,<3.4.4.0a0|>=3.4.2,<3.4.3.0a0|>=3.3.4,<3.3.5.0a0|>=3.3.2,<3.3.3.0a0',build='py36h64f37c6_1|py36h64f37c6_0|py37h64f37c6_0|py38h64f37c6_0|py37h64f37c6_1|py38h64f37c6_1']

Package pandocfilters conflicts for:
notebook -> nbconvert -> pandocfilters[version='>=1.4.1']
nbconvert -> pandocfilters[version='>=1.4.1']
jupyter -> nbconvert -> pandocfilters[version='>=1.4.1']

Package fonttools conflicts for:
matplotlib-base -> fonttools[version='>=4.22.0']
matplotlib -> matplotlib-base[version='>=3.4.3,<3.4.4.0a0'] -> fonttools[version='>=4.22.0']

Package pywinpty conflicts for:
notebook -> terminado[version='>=0.8.1'] -> pywinpty
terminado -> pywinpty

Package sip conflicts for:
matplotlib -> pyqt -> sip[version='4.18.*|>=4.19.4|>=4.19.4,<=4.19.8|4.19.13.*|>=4.19.13,<=4.19.14']
pyqt -> sip[version='4.18.*|>=4.19.4|>=4.19.4,<=4.19.8|4.19.13.*|>=4.19.13,<=4.19.14']
qtconsole -> pyqt -> sip[version='4.18.*|>=4.19.4|>=4.19.4,<=4.19.8|4.19.13.*|>=4.19.13,<=4.19.14']

Package scandir conflicts for:
importlib_metadata -> pathlib2 -> scandir
testpath -> pathlib2 -> scandir
ipython -> pathlib2 -> scandir
pickleshare -> pathlib2 -> scandir

Package olefile conflicts for:
pillow -> olefile
matplotlib-base -> pillow[version='>=6.2.0'] -> olefile

Package pandoc conflicts for:
nbconvert -> pandoc[version='>=1.12.1|>=1.12.1,<2.0.0']
jupyter -> nbconvert -> pandoc[version='>=1.12.1|>=1.12.1,<2.0.0']
notebook -> nbconvert -> pandoc[version='>=1.12.1|>=1.12.1,<2.0.0']

Package async_generator conflicts for:
nbclient -> async_generator
nbconvert -> nbclient[version='>=0.5.0,<0.6.0'] -> async_generator

like image 768
roudan Avatar asked Oct 17 '25 03:10

roudan


1 Answers

Conda is more usable when we want to install something that is not written in python. It is not the case in Mxnet. I would suggest using pip install for libraries in python.

You may take a look at this link to better understand how to use conda environments.

What is the difference between pip and conda?

Also here's the official documentation of anaconda:

https://www.anaconda.com/blog/understanding-conda-and-pip

You may go through these. One common trick to understand if we need pip install or conda install, we check if the source code of the library in question is written in python or in another language.

If it is in python, then it's highly recommended to use pip install

Otherwise, conda install.

Here, in https://pypi.org/project/mxnet/ it has been mentioned that the latest version of Mxnet works in all python version from 3.5 onwards, so pip install mxnet should work.

like image 149
Keshav Biyani Avatar answered Oct 18 '25 18:10

Keshav Biyani



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!