Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'NoneType' object has no attribute 'plot' #42

Closed
voltlog opened this issue Sep 27, 2019 · 15 comments
Closed

AttributeError: 'NoneType' object has no attribute 'plot' #42

voltlog opened this issue Sep 27, 2019 · 15 comments

Comments

@voltlog
Copy link

voltlog commented Sep 27, 2019

I'm having trouble plotting data while running on the raspberry pi 4 itself, command line. (Raspbian 10 buster).

 ./stressberry-plot out.dat -o out.png
Unable to init server: Could not connect: Connection refused
Unable to init server: Could not connect: Connection refused

(stressberry-plot:9112): Gdk-CRITICAL **: 10:13:18.390: gdk_cursor_new_for_display: assertion 'GDK_IS_DISPLAY (display)' failed

(stressberry-plot:9112): Gdk-CRITICAL **: 10:13:18.393: gdk_cursor_new_for_display: assertion 'GDK_IS_DISPLAY (display)' failed
Traceback (most recent call last):
  File "./stressberry-plot", line 10, in <module>
    sys.exit(plot())
  File "/home/pi/.local/lib/python3.7/site-packages/stressberry/cli.py", line 152, in plot
    ax1.plot(
AttributeError: 'NoneType' object has no attribute 'plot'

Any idea what might be wrong here?

@nschloe
Copy link
Owner

nschloe commented Sep 30, 2019

Any idea what might be wrong here?

Yes. Main readme:

(Use MPLBACKEND=Agg stressberry-plot out.dat -o out.png if you're running the script on the Raspberry Pi itself.)

@nschloe nschloe closed this as completed Sep 30, 2019
@voltlog
Copy link
Author

voltlog commented Oct 1, 2019

I forgot to mention in the post above that I've tried the command mentioned in the readme, I get the same error related to attribute 'plot':

MPLBACKEND=Agg stressberry-plot out.dat -o out.png
Traceback (most recent call last):
  File "/home/pi/.local/bin/stressberry-plot", line 10, in <module>
    sys.exit(plot())
  File "/home/pi/.local/lib/python3.7/site-packages/stressberry/cli.py", line 152, in plot
    ax1.plot(
AttributeError: 'NoneType' object has no attribute 'plot'

@nschloe
Copy link
Owner

nschloe commented Oct 1, 2019

Yeah, that is really weird, never seen this before. I cannot reproduce it either, so you'll have to do some debugging. The line

ax1 = fig.add_subplot()

should return an axis object, not None.

@spiff72
Copy link

spiff72 commented Oct 2, 2019

I am getting the same error here:

pi@raspberrypi:~ $ MPLBACKEND=Agg stressberry-plot out.dat -o out.png
Traceback (most recent call last):
  File "/home/pi/.local/bin/stressberry-plot", line 10, in <module>
    sys.exit(plot())
  File "/home/pi/.local/lib/python3.7/site-packages/stressberry/cli.py", line 152, in plot
    ax1.plot(
AttributeError: 'NoneType' object has no attribute 'plot'

I am running on a RasPi 4 with 4GB RAM, with the latest Raspbian updates applied.

@spiff72
Copy link

spiff72 commented Oct 2, 2019

I should add that the stressberry-run portion runs without issue. just the plot portion fails.

@spiff72
Copy link

spiff72 commented Oct 4, 2019

Can this issue be re-opened? I just checked this on a raspberry pi zero running buster, and get the same issue.

I also installed stressberry on a different pi zero running raspbian strech and the same error happens there too.

@nschloe
Copy link
Owner

nschloe commented Oct 4, 2019

that is really weird, never seen this before. I cannot reproduce it either, so you'll have to do some debugging.

@nschloe nschloe reopened this Oct 4, 2019
@voltlog
Copy link
Author

voltlog commented Oct 4, 2019

that is really weird, never seen this before. I cannot reproduce it either, so you'll have to do some debugging.

Can you confirm that you've tried the latest raspbian release, followed the readme instructions alone and it works? (I've tried on a raspberry pi 4 and the plot function does not work, giving the error mentioned above)

@spiff72
Copy link

spiff72 commented Oct 4, 2019

that is really weird, never seen this before. I cannot reproduce it either, so you'll have to do some debugging.

Can you confirm that you've tried the latest raspbian release, followed the readme instructions alone and it works? (I've tried on a raspberry pi 4 and the plot function does not work, giving the error mentioned above)

I would be curious about this too. If nschloe was to start from the current raspbian release image (buster) on a fresh install, do the instructions above work? I am thinking that there may be something that the dev has set up that may have changed with some recent updates (even updates to stretch - not just buster).

When I set this up last night on my Pi Zero with Stretch installed, I ran into a few more glitches in the process (namely the numpy issue mentioned elsewhere in this closed thread). I solved this by following the recommendation in that thread to install:

sudo apt-get install libatlas-base-dev

I didn't run into the numpy issue when installing on buster (either on Raspi 4 or Raspi Zero - both clean installs). I only had to fix my path so the .local/bin and local/bin were included.

@lagurus
Copy link

lagurus commented Oct 4, 2019

For me help,

pip3 install -U matplotlib

@spiff72
Copy link

spiff72 commented Oct 4, 2019

For me help,

pip3 install -U matplotlib

Oh snap - that worked! Thanks lagurus! What does the -U option do in this case?

EDIT: just figured out it is 'upgrade'

@moose4lord
Copy link

I was having the "AttributeError: 'NoneType' object has no attribute 'plot'" error on a fresh install of Raspbian on my new Pi 4. I ran the "pip3 install -U matplotlib" command (thanks @lagurus), which helped, but I still got this error:

pi@raspberrypi4:~ $ MPLBACKEND=Agg stressberry-plot stressberry.dat
/usr/local/lib/python3.7/dist-packages/stressberry/cli.py:197: UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.
  plt.show()

I'm a noob, so don't know what that means, but running the command "stressberry-plot stressberry.dat" (without the "MPLBACKEND=Agg" prefix) seems to work.

@nschloe
Copy link
Owner

nschloe commented Oct 5, 2019

@moose4lord That's not an error, it's a just warning (that you won't see a window with the plot, as you would expect on a desktop.)

@nschloe nschloe closed this as completed Oct 5, 2019
@voltlog
Copy link
Author

voltlog commented Oct 9, 2019

pip3 install -U matplotlib

I can confirm this fixes the problem for me too. Thanks!

@noderat
Copy link

noderat commented Dec 26, 2019

@nschloe

Yeah, that is really weird, never seen this before. I cannot reproduce it either, so you'll have to do some debugging. The line

ax1 = fig.add_subplot()

should return an axis object, not None.

A freshly installed and updated Raspbian install running pip3 install --user stressberry will only install matplotlib 3.0.2. Updating works because that feature was added in matplotlib 3.1.0+

https://matplotlib.org/3.1.0/api/api_changes.html#figure-add-subplot-with-no-arguments

Calling Figure.add_subplot() with no positional arguments used to do nothing; this now is equivalent to calling add_subplot(111) instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants