I'm not sure if this is the right thread or not, but it seems like it is close.
I don't have any work at the moment (which is bad) so I've decided to learn some python in the downtime. I also decided to do this in linux as I have no experience in linux as I actively avoided it in University. With that said I installed Linux Mint in a VM that I'm running in Windows 10, and then I installed Spyder and off I went going through some tutorials and getting my feet wet with some syntax. I'm not a noob and have experience with C#, C, C++, Visual Basic, etc., but not on a professional scale. I've programmed some small apps for work and personal projects.
So, I am going through
Data Science from Scratch and I type up the following:
Code:
from matplotlib import pyplot as plt
years = [1950, 1960, 1970, 1980, 1990, 2000, 2010]
gdp = [300.2, 543.3, 1075.9, 2862.5, 5979.6, 10289.7, 14958.3]
#create a line chart, years on x-axis, gpd on y-axis
plt.plot(years, gdp, color='green', marker = 'o', linestyle = 'solid')
#add a title
plt.title("Nominal GDP")
#add a label to the y-axis
plt.ylabel("Billions of $")
plt.show()
And when I run it inside of the Spyder IDE I get this error:
Code:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 699, in runfile
execfile(filename, namespace)
File "/usr/lib/python2.7/dist-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 81, in execfile
builtins.execfile(filename, *where)
File "/home/mdodd/markstuff/DataScience From Scratch/chapter3_1.py", line 9, in <module>
from matplotlib import pyplot as plt
ImportError: No module named matplotlib
The first thing I did was decided that matplotlib didn't exist so I remembered that the book recommended I install anaconda, so I did that, and I tested it, and it is installed. I then ran the code in Spyder again and got the same error. I messed around with some stuff and then I went to the terminal and ran the code from the terminal with:
Code:
python chapter3_1.py
And it worked as expected. So now I know I have the libraries installed correctly and that the code is correct and it's something that is wrong with the Spyder IDE, but I have no idea what and I have done a lot of googling around on it. I suspect it's something to do with my PYTHONPATH but I really don't understand how to fix it.