I'm using PyCharm 2018.1.4
If I write
from pathlib import Path
p = Path('.')
this runs fine.
On the other hand, if I write
import pathlib
p = Path('.')
I get
NameError: name 'Path' is not defined
I thought by using import pathlib I'm importing the complete library, including Path.
Compared to a terminal session:
$ bpython
bpython version 0.17.1 on top of Python 3.6.4 /Users/fanta4/anaconda3/bin/python
>>> import pathlib
>>> p = Path('.')
>>>
no problem.
And just python:
Nick-iMac:~ fanta4$ which python
/Users/fanta4/anaconda3/bin/python
Nick-iMac:~ fanta4$ python
Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 12:04:33)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
>>> import pathlib
>>> p = Path('.')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'Path' is not defined
Where is the problem in PyCharm?
In PyCharm I see python 3.6 (File > Default Settings > Project Interpreter)
Thanks!