Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 07-29-2022, 09:55 PM   #1
xxyzz
Evangelist
xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.
 
Posts: 442
Karma: 2666666
Join Date: Nov 2020
Device: none
Python can't find standard library in subprocess on Fedora

A user reported this error: https://github.com/xxyzz/WordDumb/issues/54

I'm able to fix the error by setting `PYTHONHOME` in `subprocess.run()`'s `env` parameter but I want to know why this error only occurs on Fedora.

Last edited by xxyzz; 07-30-2022 at 03:36 AM.
xxyzz is offline   Reply With Quote
Old 07-29-2022, 10:04 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,364
Karma: 27230406
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
presumably because fedora just moved to python 3.10
kovidgoyal is online now   Reply With Quote
Old 07-29-2022, 10:16 PM   #3
xxyzz
Evangelist
xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.
 
Posts: 442
Karma: 2666666
Join Date: Nov 2020
Device: none
But the same code runs fine on Fedora's python.

Code:
import subprocess

r = subprocess.run(["python3", "-m", "pip", "--version"], check=True, text=True, capture_output=True)
this would fail in calibre-debug,

`r.stderr`:
Code:
Could not find platform independent libraries <prefix>\n
Could not find platform dependent libraries <exec_prefix>\n
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]\n
Python path configuration:\n  
PYTHONHOME = (not set)\n  
PYTHONPATH = (not set)\n  
program name = 'python3'\n  
isolated = 0\n  
environment = 1\n  
user site = 1\n  
import site = 1\n 
sys._base_executable = '/usr/bin/python3'\n  
sys.base_prefix = '/tmp/t/python-n51y8gtd'\n  
sys.base_exec_prefix = '/tmp/t/python-n51y8gtd'\n  
sys.platlibdir = 'lib'\n  
sys.executable = '/usr/bin/python3'\n  
sys.prefix = '/tmp/t/python-n51y8gtd'\n  
sys.exec_prefix = '/tmp/t/python-n51y8gtd'\n  
sys.path = [\n
    '/tmp/t/python-n51y8gtd/lib/python310.zip',\n
    '/tmp/t/python-n51y8gtd/lib/python3.10',\n
    '/tmp/t/python-n51y8gtd/lib/lib-dynload',\n
]\n
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding\n
Python runtime state: core initialized\n
ModuleNotFoundError: No module named 'encodings'\n\n

Current thread 0x00007f824f149740 (most recent call first):\n
<no Python frame>\n"

Last edited by xxyzz; 07-30-2022 at 03:23 AM.
xxyzz is offline   Reply With Quote
Old 07-29-2022, 10:21 PM   #4
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,364
Karma: 27230406
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Quote:
Originally Posted by xxyzz View Post
But the same code runs fine on Fedora's python.

Code:
import subprocess

subprocess.run(["python3", "-m", "pip", "--version"], check=True, text=True, capture_output=True)
this would fail in calibre-debug
You would need to ask whoever maintains the fedora calibre package or tell your user to use the official binary.
kovidgoyal is online now   Reply With Quote
Old 07-29-2022, 10:24 PM   #5
xxyzz
Evangelist
xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.
 
Posts: 442
Karma: 2666666
Join Date: Nov 2020
Device: none
I forget to mention this is the official calibre binary, Fedora 36's package is still calibre 5.

Last edited by xxyzz; 07-29-2022 at 10:36 PM.
xxyzz is offline   Reply With Quote
Old 07-30-2022, 03:06 AM   #6
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,364
Karma: 27230406
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
The tracebackk in your bug report includes lines from the system pythons subprocess module. The only way that can happen is if you added the system python's path to sys.path, since calibre has its own python. Dont do that.
kovidgoyal is online now   Reply With Quote
Old 07-30-2022, 03:17 AM   #7
xxyzz
Evangelist
xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.
 
Posts: 442
Karma: 2666666
Join Date: Nov 2020
Device: none
No I didn't add anything to `sys.path`...

That one line of code(`subprocess.run(["python3", "-m", "pip", "--version"], text=True, capture_output=True)`) alone will get this error.

Last edited by xxyzz; 07-30-2022 at 03:22 AM.
xxyzz is offline   Reply With Quote
Old 07-30-2022, 04:26 AM   #8
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,364
Karma: 27230406
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
aaah you are running external python3 as a subprocess. You need to use the sanitize_env_vars() context manager in that case.
kovidgoyal is online now   Reply With Quote
Old 07-30-2022, 04:59 AM   #9
xxyzz
Evangelist
xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.xxyzz ought to be getting tired of karma fortunes by now.
 
Posts: 442
Karma: 2666666
Join Date: Nov 2020
Device: none
Thank you so much!
xxyzz is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
subprocess.Popen get FileNotFoundError but works fine in debug mode xxyzz Development 2 01-01-2021 08:50 PM
Find Non Standard Conversion Settings BetterRed Conversion 4 07-04-2013 10:13 AM
Using Calibre as a Python Library dwyera Development 1 07-30-2012 07:17 AM
Standard apps (games) pocketbook 302, where to find? Saille PocketBook 13 07-06-2010 11:45 AM
Is there a standard format for library eBooks? RonaldJJames General Discussions 16 03-15-2010 01:59 PM


All times are GMT -4. The time now is 10:53 PM.


MobileRead.com is a privately owned, operated and funded community.