New to Python3.5 (and MacOS) and have begun by using the PyCharm IDE. I'm using an example from Download file from web in Python 3 to download a file, but it fails at the first statement:
import urllib.request
url = 'http://example.com/'
response = urllib.request.urlopen(url)
data = response.read() # a `bytes` object
text = data.decode('utf-8')
/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5 /Users/nevd/PycharmProjects/py3/download.py
Traceback (most recent call last):
File "/Users/nevd/PycharmProjects/py3/download.py", line 4, in <module>
import urllib.request
File "/Users/nevd/PycharmProjects/py3/urllib.py", line 9, in <module>
import urllib.request
ImportError: No module named 'urllib.request'; 'urllib' is not a package
However the code works OK from Terminal, so I assume the problem is a PyCharm configuration issue. Under PyCharm File>Default Settings>Default Project>Project Interpreter
the project interpreter is 3.5.0 but below that I only see 2 Packages: pip 7.1.2
& setuptools 18.2
.
Mac OS X v10.11.1 (El Capitan) and PyCharm Community 5.0.1