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
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.
use pip install mxnet. don't use conda install mxnet. if there is an error about permission, then use pip install mxnet --user. It worked for me.
pip install mxnet
Using this will solve your no module name 'mxnet' error.
Related
I have been trying to use the torch benchmark module for profiling the code. Verified that all required imports are in place:
import torch
import torchvision
import torch.utils.benchmark
Also, these are the versions installed:
torch -> 1.4.0
torchvision -> 0.2.1
tensorflow -> 1.12.0
tensorflow-gpu -> 1.12.0
tensorboard -> 2.5.0
But I still get error: ModuleNotFoundError: No module named 'torch.utils.benchmark' while importing torch.utils.benchmark. What could be the root cause?
Have you tried to upgrade torch? I see you are using 1.4.0 but currently 1.9.0 is available.
pip install torch --upgrade
I have tested import of modules as you describe with 1.9.0 and receive no errors.
I've spent half a day trying to figure it out on my own but now I've run out of ideas and googling requests.
So basically what I want is to connect to our Snowflake database using snowflake-connector-python package. I was able to install the package just fine (together with all the related packages that were installed automatically) and my current pip3 list results in this:
Package Version
-------------------------- ---------
asn1crypto 1.3.0
azure-common 1.1.25
azure-core 1.6.0
azure-storage-blob 12.3.2
boto3 1.13.26
botocore 1.16.26
certifi 2020.6.20
cffi 1.14.0
chardet 3.0.4
cryptography 2.9.2
docutils 0.15.2
gitdb 4.0.5
GitPython 3.1.3
idna 2.9
isodate 0.6.0
jmespath 0.10.0
msrest 0.6.17
oauthlib 3.1.0
oscrypto 1.2.0
pip 20.1.1
pyasn1 0.2.3
pyasn1-modules 0.0.9
pycparser 2.20
pycryptodomex 3.9.8
PyJWT 1.7.1
pyOpenSSL 19.1.0
python-dateutil 2.8.1
pytz 2020.1
requests 2.23.0
requests-oauthlib 1.3.0
s3transfer 0.3.3
setuptools 47.3.1
six 1.15.0
smmap 3.0.4
snowflake-connector-python 2.2.8
urllib3 1.25.9
wheel 0.34.2
Just to be clear, it's a clean python-venv although I've tried it on the main one, too.
When running the following code in VScode:
#!/usr/bin/env python
import snowflake.connector
# Gets the version
ctx = snowflake.connector.connect(
user='user',
password='pass',
account='acc')
I'm getting this error:
AttributeError: module 'snowflake' has no attribute 'connector'
Does anyone have any idea what could be the issue here?
AttributeError: module 'snowflake' has no attribute 'connector'
Your test code is likely in a file named snowflake.py which is causing a conflict in the import (it is ending up importing itself). Rename the file to some other name and it should allow you to import the right module and run the connector functions.
Try importing 'connector' explicitly. I had the same error.
import pandas as pd
import snowflake as sf
from snowflake import connector
When I had this issue I had both the snowflake and snowflake-connector-python module installed in my environment, so it was confused on which one to use. If you're trying to use connector, just pip uninstall snowflake
If you have installed both snowflake and snowflake-connector-python, just uninstalling snowflake package will resolve the issue.
_
To list installed python packages, use command
pip list
I installed python 3.6 again.
I removed this line from code
#!/usr/bin/env python
It worked.
pip install snowflake-connector-python
Have you tried using this package instead in the jupyter notebook?
If anyone comes across this same issue and doesn't get reprieve from the above fixes, my install had a snowflake.py file saved to the site-packages folder.
This caused the 'import snowflake.connector' statement to attempt to import from the snowflake.py file instead of the snowflake folder, and of course couldn't find the connector module since the .py file isn't a package. Renaming or moving that file solved my problem.
I had a sub-folder named snowflake, but depending on how I run the script it either could or could not import the snowflake.connector.
I've tried import weka package in Pycharm. But it got an error.
This is for Python 3.7.4 on windows 10. And I've installed java bridge and Weka successfully.
Package Version
------------------- -------
arff 0.9
javabridge 1.0.18
numpy 1.17.3
pandas 0.25.2
pip 19.3.1
python-dateutil 2.8.0
python-weka-wrapper 0.3.15
pytz 2019.3
setuptools 40.8.0
six 1.12.0
weka 1.0.6
and I type:
import weka.core
and get the error:
File "C:/Users/dell/PycharmProjects/lab2/Source.py", line 2, in <module>
import weka.core
ModuleNotFoundError: No module named 'weka.core'
So how to fix it? Thank you
weka.core is not a Python module, as the error states.
What are you trying to achieve with this import?
If you are trying to import the jvm module (eg for starting/stopping the JVM), then do something like import weka.core.jvm as jvm.
I am not able to import category_encoders module in jupyter notebook in python 3 virtual environment.
Error
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-15-86725efc8d1e> in <module>()
9 from plotly import graph_objs
10 from datetime import datetime
---> 11 import category_encoders as ce
12
13 import sklearn
ModuleNotFoundError: No module named 'category_encoders'
Output of "which pip"
/opt/virtual_env/py3/bin/pip
Output of "pip show category_encoders" is
Name: category-encoders
Version: 1.3.0
Summary: A collection sklearn transformers to encode categorical variables as numeric
Home-page: https://github.com/wdm0006/categorical_encoding
Author: Will McGinnis
Author-email: will#pedalwrencher.com
License: BSD
Location: /opt/virtual_env/py3/lib/python3.6/site-packages
Requires: numpy, pandas, statsmodels, scikit-learn, patsy, scipy
Required-by:
Output of "pip list"
Package Version
------------------- -------
absl-py 0.7.0
astor 0.7.1
backcall 0.1.0
category-encoders 1.3.0
cycler 0.10.0
pip install --upgrade category_encoders
Now,
Restart your kernel
import category_encoders as... so on and so forth
Also,
you can checkout the sk-learn's preprocessing class CategoricalEncoder...
from sklearn.preprocessing import CategoricalEncoder
get sk-learn from here,
pip install git+git://github.com/scikit-learn/scikit-learn.git
or Simply
pip install sklearn
I was using anaconda environment.
Initially, I installed category_encoders using pip (within the conda enviornment) and it failed to resolve. Then I uninstalled ``category_encoders` from pip
pip uninstall category-encoders
and installed it using conda:
conda install -c conda-forge category_encoders
That solved the issue.
If you have given your virtual environment ('py3' for your case) the permission for accessing the system site-packages directory you can try installing the package to your base (root) environment.
Search 'pyvenv.cfg' file in your system and check if it includes:
include-system-site-packages = true
If yes, install the package to your root environment as stated here and try importing it again in your Jupyter Notebook.
You can add a cell above and type ! pip install --upgrade category_encoders
It will install the package without opening a terminal window.
I am trying to install geopandas on my Mac OS X right now.
What I have done:
• Downloaded and installed Anaconda for Python 2.7 here. Graphical installer.
• python --version returns the following result: Python 2.7.13 :: Anaconda 4.3.0 (x86_64)
• Installed geopandas using this line : conda install -c conda-forge geopandas. This command also, as I understand, installed all other required packages. Here's the list of all that command installed:
click-plugins: 1.0.3-py27_0 conda-forge
cligj: 0.4.0-py27_0 conda-forge
descartes: 1.1.0-py27_0 conda-forge
expat: 2.1.0-2 conda-forge
fiona: 1.7.3-np111py27_0 conda-forge
freexl: 1.0.2-1 conda-forge
gdal: 2.1.3-np111py27_0 conda-forge
geopandas: 0.2.1-py27_3 conda-forge
geos: 3.5.1-1 conda-forge
giflib: 5.1.4-0 conda-forge
hdf4: 4.2.12-0 conda-forge
json-c: 0.12-0 conda-forge
kealib: 1.4.6-3 conda-forge
libdap4: 3.18.3-2 conda-forge
libnetcdf: 4.4.1.1-2 conda-forge
libpq: 9.5.4-3 conda-forge
libspatialindex: 1.8.5-1 conda-forge
libspatialite: 4.3.0a-14 conda-forge
munch: 2.1.0-py27_0 conda-forge
openjpeg: 2.1.2-2 conda-forge
pcre: 8.39-0 conda-forge
proj4: 4.9.3-2 conda-forge
psycopg2: 2.6.2-py27_1 conda-forge
pyproj: 1.9.5.1-py27_0 conda-forge
pysal: 1.13.0-py27_0 conda-forge
rtree: 0.8.3-py27_0 conda-forge
shapely: 1.5.17-np111py27_2 conda-forge
xerces-c: 3.1.4-0
• geopandas appears when I run conda list
• I wrote some code in test.py:
import geopandas as gpd
gpd.read_file("osm_mexico_city/mexico-city_mexico_roads.geojson")
The problem(s):
• When I run execute python test.py in the terminal I get the following error:
Traceback (most recent call last):
File "test.py", line 1, in <module>
import geopandas as gpd
File "//anaconda/lib/python2.7/site-packages/geopandas/__init__.py", line 4, in <module>
from geopandas.io.file import read_file
File "//anaconda/lib/python2.7/site-packages/geopandas/io/file.py", line 3, in <module>
import fiona
File "//anaconda/lib/python2.7/site-packages/fiona/__init__.py", line 69, in <module>
from fiona.collection import Collection, BytesCollection, vsi_path
File "//anaconda/lib/python2.7/site-packages/fiona/collection.py", line 9, in <module>
from fiona.ogrext import Iterator, ItemsIterator, KeysIterator
ImportError: dlopen(//anaconda/lib/python2.7/site-packages/fiona/ogrext.so, 2): Library not loaded: #rpath/libpng16.16.dylib
Referenced from: //anaconda/lib/libgdal.20.dylib
Reason: Incompatible library version: libgdal.20.dylib requires version 45.0.0 or later, but libpng16.16.dylib provides version 44.0.0
• Second way I tried is through PyCharm. I have set the project interpreter to python 2.7. There geopandas does not appear in the package list, therefore PyCharm blocks even before that:
import geopandas as gpd
ImportError: No module named geopandas
Hope anyone has an idea of how to fix both.
UPDATE 1
After installing Anaconda brew doctor returns this now:
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!
Warning: Anaconda is known to frequently break Homebrew builds, including Vim and
MacVim, due to bundling many duplicates of system and Homebrew-available
tools.
If you encounter a build failure please temporarily remove Anaconda
from your $PATH and attempt the build again prior to reporting the
failure to us. Thanks!
Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.
Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:
//anaconda/bin/curl-config
//anaconda/bin/dap-config
//anaconda/bin/freetype-config
//anaconda/bin/gdal-config
//anaconda/bin/geos-config
//anaconda/bin/icu-config
//anaconda/bin/kea-config
//anaconda/bin/libpng-config
//anaconda/bin/libpng16-config
//anaconda/bin/nc-config
//anaconda/bin/pcre-config
//anaconda/bin/python-config
//anaconda/bin/python2-config
//anaconda/bin/python2.7-config
//anaconda/bin/xml2-config
//anaconda/bin/xslt-config
Seems related to this issue. How do I fix these to make my stuff work?
UPDATE 2
We can forget about the PyCharm problem, it turns out somehow I had another python 2.7 and this is the one he was suggesting. I've changed it to the Anaconda python 2.7 and now it gives the same error as the terminal output.
Faced the same problem, and finally solved this through this method:
First install geopandas using conda (This will install all dependencies)
conda install -c conda-forge geopandas
Uninstall Fiona
conda uninstall fiona
Download fiona wheel and install
(I downloaded from here https://pypi.python.org/packages/71/ea/908bf078499b30d1ec374eb5baba016a568fc8142ee6ccf72e356d20871c/Fiona-1.7.4-cp27-cp27m-macosx_10_6_intel.whl#md5=971393c23ffc552664b7c694b992fb3e)
pip install Fiona-1.7.4-cp27-cp27m-macosx_10_6_intel.whl
Reinstall geopandas
pip install git+git://github.com/geopandas/geopandas.git
Not sure what happened with Anaconda, but it turns out the dependencies were not compatible.
conda install fiona=1.6
Downgrading Fiona to 1.6 solved everything for me.