matplotlib ticker error on remote cluster - python

I have a Python code that works properly on my local machine. But when I run the same code on a remote cluster I get the following error:
Traceback (most recent call last):
from matplotlib import ticker as mtick # Import mtick for tick locating and formatting.
File "/home/nxkr/.local/lib/python2.7/site-packages/matplotlib/ticker.py", line 158, in <module>
from matplotlib import transforms as mtransforms
File "/home/nxkr/.local/lib/python2.7/site-packages/matplotlib/transforms.py", line 39, in <module>
from matplotlib._path import (affine_transform, count_bboxes_overlapping_bbox,
ImportError: libpython2.7.so.1.0: cannot open shared object file: No such file or directory
The source of error is from matplotlib import ticker as mtick, but it works properly on my local machine. matplotlib version on both local and remote cluster is 1.4.3. Why does this error occur and how to fix it?
Update
When I comment that line I backend_pdf creates the following error:
from matplotlib.backends.backend_pdf import PdfPages # Import PDF matplotlib backend.
File "/home/nxkr/.local/lib/python2.7/site-packages/matplotlib/backends/backend_pdf.py", line 35, in <module>
from matplotlib.backend_bases import RendererBase, GraphicsContextBase,\
File "/home/nxkr/.local/lib/python2.7/site-packages/matplotlib/backend_bases.py", line 45, in <module>
import matplotlib.transforms as transforms
File "/home/nxkr/.local/lib/python2.7/site-packages/matplotlib/transforms.py", line 39, in <module>
from matplotlib._path import (affine_transform, count_bboxes_overlapping_bbox,
ImportError: /home/nxkr/.local/lib/python2.7/site-packages/matplotlib/_path.so: undefined symbol: PyUnicodeUCS2_AsEncodedString
Commenting that causes pyplot to throw this error:
import matplotlib.pyplot as plt # Import matplotlib for plotting.
File "/home/nxkr/.local/lib/python2.7/site-packages/matplotlib/pyplot.py", line 27, in <module>
import matplotlib.colorbar
File "/home/nxkr/.local/lib/python2.7/site-packages/matplotlib/colorbar.py", line 32, in <module>
import matplotlib.artist as martist
File "/home/nxkr/.local/lib/python2.7/site-packages/matplotlib/artist.py", line 12, in <module>
from .transforms import Bbox, IdentityTransform, TransformedBbox, \
File "/home/nxkr/.local/lib/python2.7/site-packages/matplotlib/transforms.py", line 39, in <module>
from matplotlib._path import (affine_transform, count_bboxes_overlapping_bbox,
ImportError: /home/nxkr/.local/lib/python2.7/site-packages/matplotlib/_path.so: undefined symbol: PyUnicodeUCS2_AsEncodedString
Why is that the same version of matplotlib is creating problems on different machines?

Related

Import Error Python (dlopen() symbol not found)

I have a simple import in python code (import matplotlib.pyplot as plt), but I keep getting this error, any idea how to solve it? (Using it on VS Code, on an Apple M1 pro chip).
Traceback (most recent call last):
File "/Users/mk/Desktop/courses spring 22/EECE 433/assignment 1/code/code.py", line 4, in <module>
import matplotlib.pyplot as plt
File "/Users/mk/Library/Python/3.8/lib/python/site-packages/matplotlib/__init__.py", line 109, in <module>
from . import _api, _version, cbook, docstring, rcsetup
File "/Users/mk/Library/Python/3.8/lib/python/site-packages/matplotlib/rcsetup.py", line 27, in <module>
from matplotlib.colors import Colormap, is_color_like
File "/Users/mk/Library/Python/3.8/lib/python/site-packages/matplotlib/colors.py", line 51, in <module>
from PIL import Image
File "/Users/mk/Library/Python/3.8/lib/python/site-packages/PIL/Image.py", line 89, in <module>
from . import _imaging as core
ImportError: dlopen(/Users/mk/Library/Python/3.8/lib/python/site-packages/PIL/_imaging.cpython-38-darwin.so, 0x0002): symbol not found in flat namespace '_xcb_connect'

Attribute error whenever I import matplotlib

Everytime I import matplotlib into my python programs I get this error (here the program is just one line "import matplotlib.pyplot as plt"):
Traceback (most recent call last):
File "string.py", line 1, in \<module>
import matplotlib.pyplot as plt
File "D:\Other programs\Python38\lib\site-packages\matplotlib\__init__.py", line 94,
in \<module>
import logging
File "D:\Other programs\Python38\lib\logging\__init__.py", line 28, in \<module>
from string import Template
File "D:\programs\python\string.py", line 1, in \<module>
import matplotlib.pyplot as plt
File "D:\Other programs\Python38\lib\site-packages\matplotlib\pyplot.py", line 36, in \<module>
import matplotlib.colorbar
File "D:\Other programs\Python38\lib\site-packages\matplotlib\colorbar.py", line 40, in \<module>
import matplotlib.artist as martist
File "D:\Other programs\Python38\lib\site-packages\matplotlib\artist.py", line 17, in \<module>
_log = logging.getLogger(__name__)
AttributeError: partially initialized module 'logging' has no attribute 'getLogger' (most likely
due to a circular import)
I cannot find any logging.py anywhere. Is this some sort of bug in the lates version of matplotlib?
your script D:\programs\python\string.py, where you try to import matplotlib.pyplot as plt is named string.py and it interferes with string module from standard library. Rename that file.

I am having trouble using or importing matplotlib. This is the first line of my code: import matplotlib.pyplot as plt

These are the messages I'm receiving and I have no idea what any of them mean.
I have python 2.7.12 and have imported matplotlib.
In the command prompt window, the last update I installed was conda install matplotlib which seemed to update some stuff (conda-env-2.5.2 and conda-4.1.12), but unfortunately not the stuff I needed.
I have never used any of this before so please speak in layman's terms if possible.
Traceback (most recent call last):
File "C:\Users\user\Desktop\plotting2.py", line 1, in <module>
import matplotlib.pyplot as plt
File "C:\Python27\lib\site-packages\matplotlib\pyplot.py", line 36, in <module>
from matplotlib.figure import Figure, figaspect
File "C:\Python27\lib\site-packages\matplotlib\figure.py", line 40, in <module>
from matplotlib.axes import Axes, SubplotBase, subplot_class_factory
File "C:\Python27\lib\site-packages\matplotlib\axes\__init__.py", line 4, in <module>
from ._subplots import *
File "C:\Python27\lib\site-packages\matplotlib\axes\_subplots.py", line 10, in <module>
from matplotlib.axes._axes import Axes
File "C:\Python27\lib\site-packages\matplotlib\axes\_axes.py", line 23, in <module>
import matplotlib.dates as _ # <-registers a date unit converter
File "C:\Python27\lib\site-packages\matplotlib\dates.py", line 130, in <module>
import dateutil.parser
File "C:\Python27\lib\site-packages\dateutil\parser.py", line 38, in <module>
from calendar import monthrange, isleap
ImportError: cannot import name monthrange
It looks like there may be a conflicting module named calendar. Are there any other packages (files) called "calendar" (calendar.py) in your python path? Try opening up a new python console and type from calendar import monthrange.

module importing error exclusively when running a file

I'm trying to import and use matplotlib.pyplot in a script and I'm getting the following error:
Traceback (most recent call last):
File "<pyshell#18>", line 1, in <module>
from matplotlib import pyplot as plt
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/matplotlib/pyplot.py", line 36, in <module>
from matplotlib.figure import Figure, figaspect
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/matplotlib/figure.py", line 40, in <module>
from matplotlib.axes import Axes, SubplotBase, subplot_class_factory
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/matplotlib/axes/__init__.py", line 4, in <module>
from ._subplots import *
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/matplotlib/axes/_subplots.py", line 10, in <module>
from matplotlib.axes._axes import Axes
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/matplotlib/axes/_axes.py", line 22, in <module>
import matplotlib.dates as _ # <-registers a date unit converter
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/matplotlib/dates.py", line 126, in <module>
from dateutil.rrule import (rrule, MO, TU, WE, TH, FR, SA, SU, YEARLY,
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/dateutil/rrule.py", line 13, in <module>
from fractions import gcd
ImportError: cannot import name 'gcd'
The weird part is that I can import it just fine if I restart the Python shell and import it directly, but as soon as I try to run my script, even if I run the script and then import it after running the script to generate data, I get the error. The import line, if it matters, is always the same:
import matplotlib
from matplotlib import pyplot
My script is being run from a folder on my desktop, and I installed matplotlib in terminal with pip3.
Your file called fractions.py is shadowing the builtin module of the same name, causing problems when other libraries try to use that library. Name your file something else.

Plotting a simple graph

I am trying to plot a simple graph using python.
the code i used is as follows
import matplotlib.pyplot as plt
plt.plot([1,2,3,4])
plt.ylabel('some numbers')
plt.show()
It throws me an error called (Import Error : NO module called _path)
the error message is as follows.,
Traceback (most recent call last):
File "C:/Users/s siddharth kumar/Desktop/graph2.py", line 1, in <module>
import matplotlib.pyplot as plt
File "C:\Python27\lib\matplotlib\pyplot.py", line 26, in <module>
from matplotlib.figure import Figure, figaspect
File "C:\Python27\lib\matplotlib\figure.py", line 24, in <module>
import matplotlib.artist as martist
File "C:\Python27\lib\matplotlib\artist.py", line 7, in <module>
from transforms import Bbox, IdentityTransform, TransformedBbox, \
File "C:\Python27\lib\matplotlib\transforms.py", line 35, in <module>
from matplotlib._path import (affine_transform, count_bboxes_overlapping_bbox,
ImportError: No module named _path
Do i need to change the path of my running python in system variables or anything., ? I installed numpy,matplotlib and everything but still then I was not able to plot this simple values on the graph.

Categories