I am using Google Colab python 3, when import from python.aux.plot import choose_proj_from_xar i got error ModuleNotFoundError
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import xarray as xr
from matplotlib import animation, rc
from IPython.display import HTML
from python.aux.plot import choose_proj_from_xar
from python.aux.ml_flood_config import path_to_data
from python.aux.plot import Map
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-42-e570b5b49079> in <module>()
from IPython.display import HTML
---> from python.aux.plot import choose_proj_from_xar
from python.aux.ml_flood_config import path_to_data
from python.aux.plot import Map
ModuleNotFoundError: No module named 'python'
how to resolve this issue ? Thanks!
Related
code:
import warnings
warnings.filterwarnings("ignore")
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import os
from PIL import Image
import matplotlib
from sklearn.model_selection import train_test_split
import tensorflow as tf
import keras
from keras.models import *
from keras.layers import *
from keras.callbacks import *
from tensorflow.keras.optimizers import *
from tqdm import tqdm
import cv2
import segmentation_models as sm
%load_ext tensorboard
import datetime
from keras.utils.vis_utils import plot_model
error:
AttributeError Traceback (most recent call last)
<ipython-input-19-fb82ca23d179> in <module>
20 import cv2
21 import tensorflow as tf
---> 22 import segmentation_models as sm
23 model = tf.keras.applications.segmentation_model(model_name='mask_rcnn', weights='imagenet')
24 get_ipython().run_line_magic('load_ext', 'tensorboard')
3 frames
/usr/local/lib/python3.8/dist-packages/efficientnet/__init__.py in init_keras_custom_objects()
69 }
70
---> 71 tensorflow.python.keras.utils.generic_utils.get_custom_objects().update(custom_objects)
72
73
AttributeError: module 'keras.utils.generic_utils' has no attribute 'get_custom_objects'
libraries should be imported successfully.
my tensorflow version is 2.11.0
and i am using google colab
Either downgrade tensorflow to version 1.x or upgrade segmentation_models so that it can work with tensorflow_2.x. If you can't do both of these then use the compat behavior of TensorFlow as follows.
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
import numpy as np
from numpy.random import default_rng
import matplotlib.pyplot as plt
import line
from python import display
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
Cell In [12], line 3
1 import numpy as np
2 from numpy.random import default_rng
----> 3 import matplotlib.pyplot as plt
4 import line
5 from python import display
ModuleNotFoundError: No module named 'matplotlib'
import numpy as np
from numpy.random import default_rng
from python import display
import matplotlib.pyplot as plt
import line
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
Cell In [13], line 4
1 import numpy as np
2 from numpy.random import default_rng
----> 4 from python import display
5 import matplotlib.pyplot as plt
6 import line
ModuleNotFoundError: No module named 'python'
i wonna make graph...................................................................................
ModuleNotFoundError means there is a problem trying import a module into your application. Often this is because you don't have the module available locally (i.e. not installed). It can also be because you've mistyped the import statement or are trying to import the module using the wrong name.
In your case:
from python import display doesn't make much sense.
Python is not a package, as far as I'm aware. Where did this line of code come from? Where is the display() function you are trying to use?
----> 3 import matplotlib.pyplot as plt
ModuleNotFoundError: No module named 'matplotlib'
This means the matplotlib library is not installed.
You can install it using:
python3 -m pip install matplotlib
I'm trying to run my project from Google Colab but I keep on getting ModuleNotFoundError: No module named 'miner_config'. The structure of my project is:
import time
import hashlib
import json
import requests
import base64
from flask import Flask, request
from multiprocessing import Process, Pipe
import ecdsa
from miner_config import MINER_ADDRESS, MINER_NODE_URL, PEER_NODES
node = Flask(__name__)
This is the error:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-27-9f096205089b> in <module>()
8 import ecdsa
9
---> 10 from miner_config import MINER_ADDRESS, MINER_NODE_URL, PEER_NODES
11
12 node = Flask(__name__)
ModuleNotFoundError: No module named 'miner_config'
I am using jupyter nb running python 3.9.1 using pip to install modules etc.
All imports work smoothly except missingno.
All the modules being imported are located in the same location Python39\lib\site-packages but missingno results in Import Error.
The missingno module had been imported and it has run smoothly before but after a kernel restart, the Import Error cropped up.
ImportError Traceback (most recent call last)
<ipython-input-16-fad26a6fb4fe> in <module>
6 #Visualization
7 import matplotlib.pyplot as plt
----> 8 import missingno
9 import seaborn as sns
10 plt.style.use('seaborn-whitegrid')
~\AppData\Local\Programs\Python\Python39\Lib\site-packages\missingno\missingno.py in <module>
6 import seaborn as sns
7 import pandas as pd
----> 8 from .utils import nullity_filter, nullity_sort
9 import warnings
10
ImportError: attempted relative import with no known parent package
How to fix it?
I have tried to delete the missingno files and reinstalling it using pip install missingno but nothing works.
Running Python in shell and importing missingno, I still get the same error. There is nothing fancy in my code, a simple, generic import which showed no signs of error before kernel restart.
>>> import missingno
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\OK\AppData\Local\Programs\Python\Python39\Lib\site-packages\missingno\missingno.py", line 8, in <module>
from .utils import nullity_filter, nullity_sort
ImportError: attempted relative import with no known parent package
Try opening the missingno.py file in site-packages.
Change
from .utils import nullity_filter, nullity_sort
to
from utils import nullity_filter, nullity_sort
Having a problem importing matplotlib.pyplot into Jupyter notebook.
I uninstalled matplotlib (and seaborn) and reinstalled them again. But that didn't solve the problem.
The exact code however works in my second computer without problems.
I researched stackoverflow, and tried one thing that was suggested (please see bottom of post) - that still gave the exact same error.
Here's some relevant info
Platform : win-64, Windows 7 Enterprise
Conda version : 4.4.7
Conda-build version : 3.0.27
Python version : 3.6.4.final.0
JupyterLab : v0.27.0
Matplotlib version 2.1.2
Here's what I am trying to run:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
I get the error shown below:
Pyplot_error
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-d2e7a3f2c9b4> in <module>()
1 import pandas as pd
2 import numpy as np
----> 3 import matplotlib.pyplot as plt
---------------------------------------------------------------------------
4 import seaborn as sns
5 get_ipython().run_line_magic('matplotlib', 'inline')
~\AppData\Local\Continuum\anaconda3\lib\site-packages\matplotlib\pyplot.py in <module>()
30 from cycler import cycler
31 import matplotlib
---> 32 import matplotlib.colorbar
---------------------------------------------------------------------------
33 from matplotlib import style
34 from matplotlib import _pylab_helpers, interactive
~\AppData\Local\Continuum\anaconda3\lib\site-packages\matplotlib\colorbar.py in <module>()
34 import matplotlib.collections as collections
35 import matplotlib.colors as colors
---> 36 import matplotlib.contour as contour
---------------------------------------------------------------------------
37 import matplotlib.cm as cm
38 import matplotlib.gridspec as gridspec
~\AppData\Local\Continuum\anaconda3\lib\site-packages\matplotlib\contour.py in <module>()
19 import matplotlib.colors as colors
20 import matplotlib.collections as mcoll
---> 21 import matplotlib.font_manager as font_manager
---------------------------------------------------------------------------
22 import matplotlib.text as text
23 import matplotlib.cbook as cbook
~\AppData\Local\Continuum\anaconda3\lib\site-packages\matplotlib\font_manager.py in <module>()
56
57 import matplotlib
---> 58 from matplotlib import afm, cbook, ft2font, rcParams, get_cachedir
---------------------------------------------------------------------------
59 from matplotlib.compat import subprocess
60 from matplotlib.fontconfig_pattern import (
ImportError: DLL load failed: The specified procedure could not be found.
---------------------------------------------------------------------------
I get the same error when I try
import matplotlib as mpl
mpl.use('tkagg')
import matplotlib.pyplot as plt