I have been trying to plot a certain signal on python but it keeps giving me an error message I don't know how to solve it
from matplotlib import pyplot as plt
from matplotlib import style
import mysignals as Sig
style.use('ggplot')
style.use('dark_background')
f,pltr_arr=plt.subplots(3,sharex=True)
pltr_arr[0].plot(sig.lnputSignal_1KHz_15kHz,color='magenta')
pltr_arr[0].set_title('subplot 1',color='magenta')
pltr_arr[1].plot(sig.InputSignal_1kHz_15kHz,color='yellow')
pltr_arr[1].set_title('Subplot 1', color='yellow')
pltr_arr[2].plot(sig.InputSignal_1kHz_15lkHz,color='green')
pltr_arr[2].set_title('Subplot 1',color='green')
above is the code of what I tried and below is the error message
ModuleNotFoundError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_9776\3731026071.py in
1 from matplotlib import pyplot as plt
2 from matplotlib import style
----> 3 import mysignals as Sig
4
5 style.use('ggplot')
ModuleNotFoundError: No module named 'mysignals'
Your error is ModuleNotFoundError: No module named 'mysignals'.
This error occurred since there is no python module named mysignals.py in the same directory or in installed through pip (see pip list).
See this for detailed instructions on how to import local files
Related
Note: I am just a beginner and doing this by myself, so if you can reply with basic descriptions, that could help more.
This is the code I wrote
from matplotlib import pyplot as plt
plt.plot([2, 1], [8, 2], 'ro')
However, I get this error. I had a code using same way to import and it used to work just fine. Now that code is not working either.
C:\Users\Tuna\PycharmProjects\start\venv\Scripts\python.exe C:/Users/Tuna/PycharmProjects/start/matplotlib.py
Traceback (most recent call last):
File "C:\Users\Tuna\PycharmProjects\start\matplotlib.py", line 1, in <module>
from matplotlib import pyplot as plt
File "C:\Users\Tuna\PycharmProjects\start\matplotlib.py", line 1, in <module>
from matplotlib import pyplot as plt
ImportError: cannot import name 'pyplot' from partially initialized module 'matplotlib' (most likely due to a circular import) (C:\Users\Tuna\PycharmProjects\start\matplotlib.py)
Process finished with exit code 1
To fix, you just need to rename your file to something that isn't matplotlib.py. Python thinks you are trying to import your own file matplotlib.py to use rather than the actual module and hence why you are getting a circular reference.
This should work fine if you have matplotlib installed, if not pycharm should prompt you to install it which should be the easiest way for you to use it in your project.
I am following this tensorflow tutorial https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/install.html#protobuf-installation-compilation and I am facing some problems when testing the installation.
I installed everything except the COCO API in the tutorial and I am running the object detection demo in jupyter right now. For some reason, I get an error inside the notebook which tells me that there is "No module named 'tensorflow'". Can I still click on Run All or does this error has to be fixed?
Thanks! :)
import numpy as np
import os
import six.moves.urllib as urllib
import sys
import tarfile
import tensorflow as tf
import zipfile
from distutils.version import StrictVersion
from collections import defaultdict
from io import StringIO
from matplotlib import pyplot as plt
from PIL import Image
# This is needed since the notebook is stored in the object_detection folder.
sys.path.append("..")
from object_detection.utils import ops as utils_ops
if StrictVersion(tf.__version__) < StrictVersion('1.12.0'):
raise ImportError('Please upgrade your TensorFlow installation to v1.12.*.')
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-34f5cdda911a> in <module>
4 import sys
5 import tarfile
----> 6 import tensorflow as tf
7 import zipfile
8
ModuleNotFoundError: No module named 'tensorflow'
Okay, for some reasons, I get this error now:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-34f5cdda911a> in <module>
10 from collections import defaultdict
11 from io import StringIO
---> 12 from matplotlib import pyplot as plt
13 from PIL import Image
14
ModuleNotFoundError: No module named 'matplotlib'
You might be facing the problem of a double version of Python installed on your computer. Jupyter is trying to compile the Tensorflow tutorial file but with the wrong kernel (which should be Python 3).
The same happened to me when trying to run ipynb files in which Tensorflow was included.
So I would first recommend you to do the following:
Check the output of this command in your command line:
jupyter kernelspec list
Then it should output something similar to this: (in case of Windows OS)
python3 c:\python 3.6.8\share\jupyter\kernels\python3
If you find "python2" or any other type of version, you should remove it manually or try by using the command :
jupyter kernelspec remove python_wrong_version
Finally, if the problem is still there you can also check the link https://github.com/jupyter/notebook/issues/397 for further discussions.
I am trying to run Martin Gorner's GoogleCloudPlatform/tensorflow-without-a-phd 00_RNN_predictions_playground.ipynb and get an ImportError for both import utils_datagen and import utils_display.
I get the same error running tensorflow/tensorflow Python 2 and Jupiter/tensorflow-notebook running Python 3. I am running macOS Sierra 10.13.3 and Docker Client: Version: 18.03.1-ce
How do I access utils_datagen or work around it?
Thanks
Lew
import numpy as np
import utils_datagen
import utils_display
from matplotlib import pyplot as plt
import tensorflow as tf
print("Tensorflow version: " + tf.__version__)
print("Hello World and Lew 30 May")
And get:
ImportError Traceback (most recent call last)
<ipython-input-2-0f00155f1447> in <module>()
1 import numpy as np
----> 2 import utils_datagen
3 import utils_display
4 from matplotlib import pyplot as plt
5 import tensorflow as tf
ImportError: No module named utils_datagen
Solved by comment from #Y. Luo. In trying to simplify my file string, I only partially cloned the Gorner GitHub file into my host file and missed the utils_datagen file. Now python can find it.
Close this thread.
Here is an issue some of you might have already encountered : I just installed matplotlib using :
pip install matplotlib
on my OS X El Capitan Version 10.11.1. It seems to me that the installation went well, and the packages are properly located in /usr/local/lib/python2.7/site-packages
I get no problem when I try to import matplotlib using :
import matplotlib
Now, when I try to import matplotlib.pyplot in a python script, using :
import matplotlib.pyplot as plt
the program starts hanging, and I have to interrupt it using Keyboard Ctrl + C.
Besides, when I only import matplotlib and try to run this piece of code :
import matplotlib
matplotlib.pyplot
I get this message in the terminal Session :
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'pyplot'
Does anyone have a solution to fix this problem ?
I'm trying to run the contourf example from the matplotlib documentation.
When I run it from a python shell, everything works well, but when I run it as a script (python contourf_demo.py), the following error rises:
Traceback (most recent call last):
File "matplotlib.py", line 3, in
import matplotlib.pyplot as plt
File "/home/user/dir/contourf_demo.py", line 3, in
import matplotlib.pyplot as plt
ImportError: No module named pyplot
I'm using Ubuntu 12.04, and the problem comes when importing:
import matplotlib.pyplot as plt
I have tried using different ways to call the import (such as from matplotlib import pyplot), but it doesn't work neither.
You can't import a module named XYZ from a file called XYZ.py, because Python would interpret that you are trying to import the file itself.
Change your file from matplotlib.py to anything else.