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

Using pyplot from a .py file #9

Open
jpw419 opened this issue Apr 6, 2020 · 3 comments
Open

Using pyplot from a .py file #9

jpw419 opened this issue Apr 6, 2020 · 3 comments

Comments

@jpw419
Copy link

jpw419 commented Apr 6, 2020

When trying to run a plot function from a .py file we get the error "plt not defined". Thereby is seems as if "matplotlib.pyplot" hasn't been loaded. It works fine when we run in a notebook.

@JeppeDruedahl
Copy link
Contributor

Do your .py file include the import statement?

import matplotlib.pyplot as plt

@jpw419
Copy link
Author

jpw419 commented Apr 6, 2020

Works now, thanks.

Is there a way to avoid having to import libraries in both the notebook and the script. It does not seem to work even though we import the script after the libraries?

@JeppeDruedahl
Copy link
Contributor

You need have the import statement both in the script and the notebook if the package is used directly both in the script and the notebook.

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

2 participants