Hello everybody, I’m really sorry if it isn’t the right sub-forum to ask this question, but couldn’t find a better.
I’m creating an application that requires cruses, but when I tried to import it on my python file, I kept getting the error message ModuleNotFoundError: No module named '_curses' After a bit of research, I found out it was a common error on windows, and that I needed to re-install it. I downloaded the WHL file and installed it via pip. But even doing so, the error keep occuring. no module named '_curses'
Now I really don’t know what i’m doing wrong, I downloaded the file from This Website which was given on several forums. And even when checking with pip, I’m told that curses is correctly installed. I really don’t know what i’m doing wrong, any help is appreciated.
There I cannot say since this is not something I am familiar with. With any luck an advanced Python user with experience in this module will pipe in. Barring that, you may need to do some more web searching.
Which version of curses did you download, and what does python print when you start it in interactive mode?
How did you install it, and what was the output?
Did you install it in the same python installation that you’re using to run your program? How are you determining that?
I suggest opening some form of terminal, and using the command python (with no arguments) to display the version, exit, and download the corresponding file, and then do python -m pip install nameofthefileyoudownloaded.whl
followed by running python again python
And attempting to import
>>> import curses
Note that these all use the same python installation, they all use the same python executable (avoiding pip’s executable because it could be something else, better to invoke the module, at least since I have nothing to tell me they’re the same)
If you used --force or --forced or -f or whatever pip likes to call it, then you shouldn’t expect it to work. That’s in no vague terms saying it did not fit.
when I try to reinstall it whilst it’s already installed, I get this output :
Requirement already satisfied: curses==2.2+utf8 from file:///D:/Nouveau%20dossier/curses-2.2%2Butf8-cp36-cp36m-win_amd64.whl in c:\users\gaufre a\appdata\local\programs\python\python36\lib\site-packages (2.2+utf8)
I double checked and the folder it’s installed in is in the paths of my python interpreter (I used pycharm to code) and I think that the error might come to pycharm rather than in the installation of curses :
>>> import curses
>>> import inspect
>>> lines = inspect.getsource(curses.initscr)
import _curses, curses
# we call setupterm() here because it raises an error
# instead of calling exit() in error cases.
stdscr = _curses.initscr()
for key, value in _curses.__dict__.items():
if key[0:4] == 'ACS_' or key in ('LINES', 'COLS'):
setattr(curses, key, value)
>>> import _curses
<module '_curses' from 'C:\\Users\\Gaufre A\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-packages\\_curses.cp36-win_amd64.pyd'>
^ this is what I get when trying to use curses in CMD, but I get the error message where _curses isn’t installed when using pycharm.
However It looks like both the modules curses and _curses are installed alright. It bugs solely on pycharm, but the modules are installed in C:\users[…]\Python36\lib\site-packages and this path is in my pycharm interpreter, at least file://C:/Users/Gaufre A/AppData/Local/Programs/Python/Python36/Lib is.
I’m still a beginner in python, but cannot figure out why the pycharm interpreter cannot find _curses ?
whereas I get C:\Users\Gaufre A\PycharmProjects\Myproject\venv\Scripts\python.exe when trying with pycharm. Do you know if there is a way to either tell pycharm to use the same version of python as my CMD or to install curses on the other version ? Sorry if i’m beeing a bit needy, I’m really struggling with those python installers.
I know nothing pycharm-specific, shouldn’t you be looking in menus and/or googling for that?
(I don’t know what IDE’s are good for except maybe handling very large pieces of code but that’s a problem of itself. That and providing tools on windows, but again, that’s a problem of itself)
Update : Apparently It came from a path problem in pycharm, I uninstalled curses, reinstalled it and made sure the path in pycharm to the module was correctly set. Now it’s working fine, sorry for the bother
Reinstalling shouldn’t have done anything should it?
And if your project has its own venv, then isn’t that where the module should be installed, rather than adding part of another installation to your python path, kind of a frankenstein kind of thing to do… I won’t argue it doesn’t do what you want though.