Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
curses issue
#1
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.
Reply
#2
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"?
Reply
#3
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$
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  I want to be able to scroll up in curses to see previous text. Caiden 1 741 Jul-28-2023, 01:15 PM
Last Post: deanhystad
  How to make curses.border() use A_BOLD atttribute? pjfarley3 0 4,819 Feb-03-2021, 11:22 PM
Last Post: pjfarley3
  Curses script doesn't work wavic 1 4,133 Jan-08-2021, 09:11 PM
Last Post: wavic
  Why aren't all curses panel functions supported in python curses.panel? pjfarley3 2 2,652 Jul-22-2020, 11:08 PM
Last Post: pjfarley3
  curses library autompav96 2 2,878 Mar-02-2019, 02:12 AM
Last Post: woooee
  curses key codes not working jgrillout 0 2,997 Feb-11-2019, 01:46 AM
Last Post: jgrillout
  Pretty table and curses? MuntyScruntfundle 0 2,880 Oct-16-2018, 10:22 AM
Last Post: MuntyScruntfundle
  curses.initscr doesn't work zaphod424 3 9,754 Feb-28-2018, 12:36 PM
Last Post: Gribouillis
  Curses could not find terminal Solstice 13 17,011 Jan-06-2018, 07:56 AM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020