wustho / epr

CLI Epub Reader
MIT License
1.21k stars 49 forks source link

No module named '_curses' #31

Closed Kabouik closed 4 years ago

Kabouik commented 4 years ago

First of all, thanks a lot for your work. epr looks fantastic and I can't wait to be able to use it.

I was trying to install it on SailfishOS using pip but I got an error during installation related to _curses module missing. I tried also to execute the epr.py file directly fetched from git, but I get a similar issue:

[nemo@Sailfish Downloads]$ python3 epr.py 
Traceback (most recent call last):
  File "epr.py", line 50, in <module>
    import curses
  File "/usr/lib/python3.8/curses/__init__.py", line 13, in <module>
    from _curses import *
ModuleNotFoundError: No module named '_curses'

Here are the ncurses packages I have currently instaled:

Information for package ncurses:
--------------------------------
Repository     : jolla                           
Name           : ncurses                         
Version        : 6.1+git1-1.4.1.jolla            
Arch           : armv7hl                         
Vendor         : meego                           
Installed Size : 167.7 KiB                       
Installed      : Yes (automatically)             
Status         : up-to-date                      
Source package : ncurses-6.1+git1-1.4.1.jolla.src
Summary        : Ncurses support utilities       

Information for package ncurses-base:
-------------------------------------
Repository     : jolla                           
Name           : ncurses-base                    
Version        : 6.1+git1-1.4.1.jolla            
Arch           : armv7hl                         
Vendor         : meego                           
Installed Size : 320.4 KiB                       
Installed      : Yes (automatically)             
Status         : up-to-date                      
Source package : ncurses-6.1+git1-1.4.1.jolla.src
Summary        : Descriptions of common terminals

Information for package ncurses-devel:
--------------------------------------
Repository     : jolla                                    
Name           : ncurses-devel                            
Version        : 6.1+git1-1.4.1.jolla                     
Arch           : armv7hl                                  
Vendor         : meego                                    
Installed Size : 352.7 KiB                                
Installed      : Yes                                      
Status         : up-to-date                               
Source package : ncurses-6.1+git1-1.4.1.jolla.src         
Summary        : Development files for the ncurses library

Information for package ncurses-libs:
-------------------------------------
Repository     : jolla                           
Name           : ncurses-libs                    
Version        : 6.1+git1-1.4.1.jolla            
Arch           : armv7hl                         
Vendor         : meego                           
Installed Size : 504.3 KiB                       
Installed      : Yes (automatically)             
Status         : up-to-date                      
Source package : ncurses-6.1+git1-1.4.1.jolla.src
Summary        : Ncurses libraries 

I tried installing ncurses-libs and ncurses-term but that didn't help. I couldn't see the minimal ncurses versions epr depend on in the README. Does it need a more recent installation of ncurses?

wustho commented 4 years ago

Hey there, thanks... I don't think epr uses ncurses but python package named curses... Have you tried to install curses with pip install curses?

I am not familiar with SailfishOS, I'll try having a look at it...

Kabouik commented 4 years ago

Unfortunately I can't find any curses module using pip. Is that the exact name?

[nemo@Sailfish ~]$ pip install curses
Defaulting to user installation because normal site-packages is not writeable
ERROR: Could not find a version that satisfies the requirement curses (from versions: none)
ERROR: No matching distribution found for curses
[nemo@Sailfish ~]$ pip3 install curses
Defaulting to user installation because normal site-packages is not writeable
ERROR: Could not find a version that satisfies the requirement curses (from versions: none)
ERROR: No matching distribution found for curses

Once pip is installed and provided that the modules are available for arm, I don't think there are any peculiarities about SailfishOS. This is the packages I currently have:

[nemo@Sailfish ~]$ pip list
Package     Version
----------- ---------
asciimatics 1.11.0
asciinema   2.0.2
curses-menu 0.5.0
Cython      0.29.19
future      0.18.2
keyboard    0.13.5
Lyvi        2.0-git
meson       0.50.1
Pillow      5.4.1
pip         20.1.1
plyr        1.0.2
psutil      5.7.0
pyfiglet    0.8.post1
pygobject   3.24.1
setuptools  41.2.0
urwid       2.1.0
wcwidth     0.1.9

I installed curses-menu when trying to solve the issue with epr, but that didn't change the error.

Kabouik commented 4 years ago

Some progress after installing curses-util, but it still looks like missing dependencies:

[nemo@Sailfish ~]$ pip install curses-util
Defaulting to user installation because normal site-packages is not writeable
Collecting curses-util
  Downloading curses-util-0.0.25.tar.gz (6.5 kB)
Using legacy setup.py install for curses-util, since package 'wheel' is not installed.
Installing collected packages: curses-util
    Running setup.py install for curses-util ... done
Successfully installed curses-util-0.0.25

[nemo@Sailfish epr]$ python epr.py 
Traceback (most recent call last):
  File "epr.py", line 61, in <module>
    from urllib.parse import unquote
ImportError: No module named parse

[nemo@Sailfish epr]$ pip install parse
Defaulting to user installation because normal site-packages is not writeable
Collecting parse
  Downloading parse-1.15.0.tar.gz (29 kB)
Using legacy setup.py install for parse, since package 'wheel' is not installed.
Installing collected packages: parse
    Running setup.py install for parse ... done
Successfully installed parse-1.15.0

[nemo@Sailfish epr]$ python epr.py 
Traceback (most recent call last):
  File "epr.py", line 61, in <module>
    from urllib.parse import unquote
ImportError: No module named parse

I'm not sure which one is missing here. Shouldn't pip automatically install dependencies?

Note that the error is unchanged after installing curses-util if I try to run epr.py with python3:

[nemo@Sailfish epr]$ pip3 install curses-util
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: curses-util in /home/nemo/.local/lib/python3.8/site-packages (0.0.25)

[nemo@Sailfish epr]$ python3 epr.py 
Traceback (most recent call last):
  File "epr.py", line 50, in <module>
    import curses
  File "/usr/lib/python3.8/curses/__init__.py", line 13, in <module>
    from _curses import *
ModuleNotFoundError: No module named '_curses'
wustho commented 4 years ago

Hey there, I've been looking up SailfishOS... And what I found so far is that cmiiw SailfishOS probably is not based on any Linux distribution. As far as I know curses python pkg only supported in Linux and Mac officially and windows unofficially...

Kabouik commented 4 years ago

Uh, no I don't think that's correct. SailfishOS most definitely is Linux. It runs a Linux kernel, has a full blown / and /home, runs Wayland, bash by default, installs rpm packages with zypper, can run flatpaks, and has all base packages other distributions have.

That does not mean epr can run easily on it, perhaps some required dependencies are not available in the repository, but I don't know which ones I should check. I have other ncurses applications running on it at the moment, but I don't know if they use the python curses or the base Linux ncurses. Do you know if somehow python curses is limited to some architectures only, and is available for arm for instance?

Kabouik commented 4 years ago

Those are the curses occurrences I can find using pip 20.1.1 from /usr/lib/python3.8/site-packages/pip (python 3.8):

[nemo@Sailfish ~]$ pip search curses
livestreamer-curses (1.5.2)      - Livestreamer-curses is a curses frontend to livestreamer
curses-ex (0.3)                  - Provide additional curses functions.
pycopy-curses (0.0.0)            - Dummy curses module for Pycopy
micropython-curses (0.0.0)       - Dummy curses module for MicroPython
haddock-curses (0.1.5)           - Random curses from Captain Haddock.
windows-curses (2.1.0)           - Support for the standard curses module on Windows
toga-curses (0.0.0)              - A Curses backend for the Toga widget toolkit.
polka-curses (1.3.0)             - The curses interface for the Polka website (https://polka.academy/)
curses-menu (0.5.0)              - A simple console menu system using curses
  INSTALLED: 0.5.0 (latest)
galaxie-curses (0.3.3)           - Galaxie Curses is a free software ToolKit for the NCurses API
curses-ui (0.0.2)                - Curses UI with native window management and keyboard support
multitail-curses (1.0.5)         - A curses-based utility script for tailing multiple files simultaneously.
curses-util (0.0.25)             - 
  INSTALLED: 0.0.25 (latest)
curses-questions (1.4)           - 
pocket-curses (0.1)              - An ncurses interface to Pocket API
Canto-curses (0.9.9)             - Next-gen console RSS/Atom reader
youtube-curses (0.1)             - YouTube browser built with ncurses
curses-snake (1.0.3)             - Snake game in console based on cureses.
curses-2048 (1.4)                - 2048 implementation with python and ncurses
cursetup (0.0.5)                 - avoid cursing at curses
curses-check-for-keypress (0.3)  - curses_check_for_keypress: loop until user presses a key.
hexes (0.4.0)                    - Curses for humans.
cursed (0.2.1)                   - Simplified curses
cpager (0.0.6)                   - Curses Pager
cpick (0.1.3)                    - Curses List Picker
cansi (0.0.4)                    - Curses ANSI Parser
shipit (0.0)                     - A curses interface to GitHub
cfortune (0.0.2)                 - Curses Fortune Browser
purses (0.0.12)                  - Purses, a Pandas Curses
ncmpy (1.5.6)                    - a curses mpd client;
cursebox-lib (1.0.2)             - Curses made simple
checkmk-commander (1.3.0)        - Curses interface to Checkmk Raw.
mccurse (0.5.1)                  - Minecraft Curse CLI Client
vdgalcon (1.12)                  - Galactic Conquest in curses, on VisiData
battleship (0.1a)                - a battleship game with a curses interface
SimpleMenu (1.2)                 - Create simple Curses menus
pysysmon (0.0.25)                - A curses-based system monitor.
pymatrix-rain (0.1.0)            - matrix rain using curses
pamixer (0.1.4)                  - PulseAudio Curses Mixer Application
aneris (0.6)                     - curses time/project planner
skyCurses (2.0.15.post5)         - Official curses client for the SkyChat
klipz (0.2.2)                    - Clipboard manager using curses
pyctu (0.1dev)                   - A curses interface to configure xbees
Tymeventure (0.1.2)              - A curses-based adventure game
ezcurses (0.3.1)                 - library to help with curses programming
cpyvke (1.2.7)                   - A Kernel and variable explorer in Curses
cursedmongo (0.1)                - A curses based MongoDB browser
comp (0.4.6)                     - Curses Omni Media Player
sshplaces (0.1.15)               - A curses menu of ssh places.
pubnub_curses (1.5.2)            - PubNub Curses Terminal Client
tmsg (0.1)                       - A curses based client for Facebook Messenger
Wikicurses (1.4)                 - A simple curses interface for accessing Wikipedia.
tinywin (0.2.5)                  - A tiny Curses window management library.
cursy (1.0.1)                    - Little and simple wrapper for curses application.
igrepper (0.0.2)                 - Interactive curses-based grepping tool
pulsemixer (1.5.1)               - pulsemixer - CLI and curses mixer for PulseAudio
py_curses_editor (1.2.1)         - A configurable curses text editor window
diet_analysis (0.1)              - Curses-based diet logging tool
interactive-input (0.5.1)        - curses based interactive value input
gunicorn-console (0.1.16)        - A curses application for managing gunicorn processes.
pymarietje (0.1.0a2)             - Curses client for MarietjeD music daemon
culour (0.1)                     - Print colored strings in a curses window
splutter (0.1.0)                 - A modern curses UI framework for Python.
dbcurses (0.0.1)                 - Curses-based application for database visualization
cursesinquirer (0.1.1)           - A library to create curses based CLIs
clockr (1.0)                     - Simple curses clock written in Python
booger (0.4.5)                   - Pretty curses-based nose frontend
mmw (1.1)                        - This is a library for displaying curses-like windows
tyrs (0.6.2)                     - Twitter and Identica client using curses
pyCDK (0.1)                      - Python binding to the Curses Development Kit
snipe-im (0.dev4)                - curses client for persistent IM systems
treepick (0.1.4)                 - Curses Tree Style Path Picker
ssfm (0.0.1)                     - Curses based File Manager application
pyramid_bpython_curses (0.1.3)   - bpython bindings for Pyramid pshell in a curses variant
Glances (3.1.4.1)                - A cross-platform curses-based monitoring tool
  INSTALLED: 3.1.4.1 (latest)
xmlcurses (1.2.2)                - An interface for python's curses library using XML
pytermfx (0.4.3)                 - Terminal interaction and formatting for Python without curses
curseradio-improved (0.3.8)      - An improved Curses interface for listening to internet radio.
PyTone (2.2.4)                   - Powerful music jukebox with a curses based GUI.
blkmenu (0.3.1)                  - Tiny curses wrapper around lsblk and udisksctl
Pygcurse (1)                     - Curses emulator module that runs on top of Pygame
pycpmc (0.1.1)                   - A curses-based CPM (typing speed) calculator.
xoinvader (0.2.0)                - (not so) small python curses space game
UniCurses (1.2)                  - A unified OS-independent Curses wrapper for Python
juc2 (0.1.1)                     - juc2 - Just Use Curses (Mark 2)
eichhoernchen (2.0)              - Lightweight curses-based time tracking tool.
cplay-ng (3.0.0)                 - A curses front-end for various audio players
UniCurses-for-Python (1.2)       - A unified OS-independent Curses wrapper for Python
dabbiew (0.6)                    - A curses-based DataFrame viewer inspired by TabView.
gremlin (0.6)                    - Curses-based command-line scripting library
cursgame (0.2.0)                 - An easy interface for writing games using curses.
curtsies (0.3.1)                 - Curses-like terminal wrapper, with colored strings!
visidata (1.5.2)                 - curses interface for exploring and arranging tabular data
sdreaper (1.0.1)                 - CLI and curses UI for talking to Arduino Reaper library
winCurses (0.2.1)                - A curses wrapper to draw some HTML-like windows
esc-calc (1.0.0)                 - extensible stack-based RPN calculator based on curses
Elatom (1.0.10)                  - Podcast downloader in Python 3 with Curses and Tkinter interfaces.
humu-download (1.1.5)            - CLI and curses UI for dowloading Humu data files
zeitzono (0.4.1)                 - city based timezone converter with a curses (TUI) interface
pacurses (0.1.1)                 - A curses graphical interface to the PulseAudio sound system for the terminal.

However, I suppose some of them are limited to just some distributions or all architectures (?), that might be the problem.

Kabouik commented 4 years ago

I believe this might be related: https://github.com/jquast/blessed/issues/99#issuecomment-314238398

Perhaps I would have more luck trying to build Python on my device (I should have the ncurses headers), but that appears risky considering I have already several things running on the python packages shipped in my repo. Not sure yet if I should try, but that's sad, I really wanted to get epr working.

In any case, it is probably not an epr issue, sorry about that.

Kabouik commented 4 years ago

Confirmed here: https://together.jolla.com/question/213413/python-37-missing-curses/?answer=213491#post-id-213491

Our version of Python was compiled without curses support, but this should be fixed soon. In the mean time I could build my own (but I think I'll just wait).

[Edit] In the end I couldn't resist and installed the version of python compiled with curses support that the community already provided. It fixed some apps depending on curses too, like rtv or glances, but unfortunately the issue below persists with epr so maybe there is something specific here in the way epr requirses curses?

[nemo@Sailfish ~]$ pip3 install git+https://github.com/wustho/epr.git
Defaulting to user installation because normal site-packages is not writeable
Collecting git+https://github.com/wustho/epr.git
  Cloning https://github.com/wustho/epr.git to /tmp/pip-req-build-9ss3222x
  Running command git clone -q https://github.com/wustho/epr.git /tmp/pip-req-build-9ss3222x
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3.8 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-9ss3222x/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-9ss3222x/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-2gk6f1pt
         cwd: /tmp/pip-req-build-9ss3222x/
    Complete output (9 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-req-build-9ss3222x/setup.py", line 3, in <module>
        from epr import __version__, __author__, __url__, __license__
      File "/tmp/pip-req-build-9ss3222x/epr.py", line 50, in <module>
        import curses
      File "/usr/lib/python3.8/curses/__init__.py", line 13, in <module>
        from _curses import *
    ModuleNotFoundError: No module named '_curses'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
wustho commented 4 years ago

Ahh thanks for troubleshooting this issue... Sorry can't help much, I'm unfamiliar with sailfishOS and having no means to experiment with it...

Kabouik commented 4 years ago

Just wanted to let you know that in the end, since the issue probably is on my end with Python being built without curses, I installed bk through Rust, which is inspired by your work on epr. It works for me thanks to the easy Rust install, but epr will probably work on my device too once Python is updated.

The problem I have right now is I manually installed a version of Python built with curses, but it's version 3.7 whereas the version I had previously from my official distribution repository was 3.8, and somehow some apps manage to use Python 3.7 (like glances or rtv), but some others probably still try to use the most recent python3 version even though it was not built with curses, like epr and term-tris. Hopefully this will all get solved when Python 3.8 is updated with curses support and I can scrap the community built version of Python 3.7.