I have a fresh install of Debian 10 /lxde. The installed Python3 version is 3.7.3 I intended to learn how to use the curses with Python (
https://docs.python.org/3/howto/curses.html). I immediately encountered trouble, with the first example. Statement:
from curses import wrapper triggers an error:
ImportError: cannot import name 'wrapper' from 'curses'.
Googling did not take me anywhere close to a solution.
I do apologize for posting here, I realize this is not about coding, but more like installation and setup of python environment, but it seemed to be less wrong than the other possibilities.
Can you show the full output from
python -V
(or "python3" or however you are invoking your python) and
python -c "from curses import wrapper"
?
Do you have a file called curses.py in the current directory? That will show this behaviour. Just rename that file to something else.
debian@vps-12345678:~/source/py$ ls -la
total 32
drwxr-xr-x 2 debian debian 4096 Jun 29 13:56 .
drwxr-xr-x 4 debian debian 4096 Jun 29 13:56 ..
-rw-r--r-- 1 debian debian 12551 Jun 29 13:56 main.py
-rw-r--r-- 1 debian debian 161 Jun 29 13:56 wim.py
-rw-r--r-- 1 debian debian 305 Jun 29 13:56 x.py
debian@vps-12345678:~/source/py$ sudo python3 -c "from curses import wrapper"
debian@vps-12345678:~/source/py$ cp x.py curses.py
debian@vps-12345678:~/source/py$ sudo python3 -c "from curses import wrapper"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/debian/source/py/curses.py", line 1, in <module>
from curses import wrapper
ImportError: cannot import name 'wrapper' from 'curses' (/home/debian/source/py/curses.py)
debian@vps-12345678:~/source/py$ rm curses.py
debian@vps-12345678:~/source/py$ sudo python3 -c "from curses import wrapper"
debian@vps-12345678:~/source/py$