1

I'm trying to run the following simple lines of Python code:

import numpy as np
import matplotlib.pyplot as plt

x = np.array([1, 2, 3])
y = np.array([4, 5, 6])

plt.plot(x, y)
plt.show()

But 'm getting the following error for the plt.show() line:

Traceback (most recent call last):
  File "/home/user/Pycharm/someproject/sam.py", line 36, in <module>
    plt.show()
  File "/home/user/Programs/miniconda/envs/plot/lib/python3.10/site-packages/matplotlib/pyplot.py", line 612, in show
    return _get_backend_mod().show(*args, **kwargs)
  File "/home/yz8zdw/Programs/pycharm-2024.1.3/plugins/python/helpers/pycharm_matplotlib_backend/backend_interagg.py", line 41, in __call__
    manager.show(**kwargs)
  File "/home/yz8zdw/Programs/pycharm-2024.1.3/plugins/python/helpers/pycharm_matplotlib_backend/backend_interagg.py", line 144, in show
    self.canvas.show()
  File "/home/yz8zdw/Programs/pycharm-2024.1.3/plugins/python/helpers/pycharm_matplotlib_backend/backend_interagg.py", line 80, in show
    FigureCanvasAgg.draw(self)
  File "/home/user/Programs/miniconda/envs/plot/lib/python3.10/site-packages/matplotlib/backends/backend_agg.py", line 387, in draw
    self.figure.draw(self.renderer)
  File "/home/user/Programs/miniconda/envs/plot/lib/python3.10/site-packages/matplotlib/artist.py", line 95, in draw_wrapper
    result = draw(artist, renderer, *args, **kwargs)
  File "/home/user/Programs/miniconda/envs/plot/lib/python3.10/site-packages/matplotlib/artist.py", line 72, in draw_wrapper
    return draw(artist, renderer)
  File "/home/user/Programs/miniconda/envs/plot/lib/python3.10/site-packages/matplotlib/figure.py", line 3161, in draw
    self.patch.draw(renderer)
  File "/home/user/Programs/miniconda/envs/plot/lib/python3.10/site-packages/matplotlib/artist.py", line 72, in draw_wrapper
    return draw(artist, renderer)
  File "/home/user/Programs/miniconda/envs/plot/lib/python3.10/site-packages/matplotlib/patches.py", line 632, in draw
    self._draw_paths_with_artist_properties(
  File "/home/user/Programs/miniconda/envs/plot/lib/python3.10/site-packages/matplotlib/patches.py", line 617, in _draw_paths_with_artist_properties
    renderer.draw_path(gc, *draw_path_args)
  File "/home/user/Programs/miniconda/envs/plot/lib/python3.10/site-packages/matplotlib/backends/backend_agg.py", line 131, in draw_path
    self._renderer.draw_path(gc, path, transform, rgbFace)
ValueError: object __array__ method not producing an array

Environment information:

python                    3.8.20
numpy                     1.16.0
matplotlib                3.7.5

What's causing this issue?

1 Answer 1

1

You are using an old version of numpy. numpy 1.16.0 supports Python 2.7, 3.4 - 3.7 whilst matplotlib 3.7.5 supports Python 3.8 - 3.12.

One way to resolve your issue is to upgrade numpy to a version that supports Python >=3.8. For example you can install numpy 1.24.4.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.