PyCharm / OS X El Capitan / Python 3.5.2 - matplotlib not working in script
<p>Python noob here, apologies if this is has an obvious answer I should know. I'm using Python 3.5.2 via PyCharm in OSX El Capitan and I'm trying to run the following simple script to practise with matplotlib:</p>

<pre><code>import matplotlib.pyplot as plt
year = [1950,1970,1990,2010]
pop = [2.159,3.692,5.263,6.972]
plt.plot(year,pop)
plt.show()
</code></pre>

<p>If I execute this line by line in PyCharm's Python console, it works fine. If I execute it as an entire script, I get this error:</p>

<pre><code>/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5/Users/Cuckoo/Dropbox/Python/test.py
Traceback (most recent call last):
  File "/Users/Cuckoo/Dropbox/Python/test.py", line 1, in &lt;module&gt;
    import matplotlib.pyplot as plt
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/matplotlib/__init__.py", line 115, in &lt;module&gt;
    import tempfile
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/tempfile.py", line 45, in &lt;module&gt;
    from random import Random as _Random
ImportError: cannot import name 'Random'

Process finished with exit code 1
</code></pre>

<p>Can anyone please explain what has gone wrong and better still, how I can fix it?</p>

<p>This can be caused by having another Python script in your project named <code>random.py</code> that is overriding the original library named Random.</p>

<p>Try to rename or remove the <code>random.py</code> file and your script should work from within PyCharm and the command line.</p>

python osx matplotlib pycharm