0

With Jupiter Notebook I was able to run the following code to display a simple chart.

import matplotlib.pyplot as plt

squares = [1, 4, 9, 16, 25]
plt.plot(squares)
plt.show()

Now I tried the same in sublime text and it does not work, I am always getting the following error message:

ModuleNotFoundError: No module named 'matplotlib'

I tried to change the Python build system with the following code, but it did not work.

{
    "cmd": ["python", "-u", "$file"],
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python",
    "shell": true
}

Does anyone have an idea how I have to move the matplotlib library to use it within sublime text?

Thanks in advance!

  • `shell_cmd` does the same thing as using `cmd` and `shell`; changing from one to the other will have no effect. Have you installed `matplotlib`? Are you sure that `python` is the appropriate version of Python? (i.e. do you have version 2 and 3 installed?) – OdatNurd Mar 10 '19 at 22:08
  • @OdatNurd yes, I have installed `matplotlib` and it works with anaconda. Regarding python I got the version 3.6.5. I think the problem is that the library is installed for the path of anaconda, which sublime text does not find. Do you have an idea regarding that? – boersencrack Mar 11 '19 at 20:43
  • Unfortunately I'm not familiar with Anaconda; do you run it via `python` as well? On some systems, `python` represents Python 2 and `python3` is needed for Python 3, for example. Generally speaking, whatever you run in the terminal should work in Sublime, so long as you use the same command in both places. If that doesn't work, there may be some environment variable setup that needs to happen so that Sublime executes things the same way as the terminal does. – OdatNurd Mar 11 '19 at 21:24

1 Answers1

0

I solved my problem by deleting anaconda (and matplotlib with it) and loading anaconda again. This might be a little strange, but it worked and my simple code example is working now.

For deleting anaconda I justed the following manual: How to uninstall Anaconda completely from MacOS