Skip to content

ModuleNotFoundError: No module named 'encodings' #310

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
buxel opened this issue Apr 16, 2021 · 11 comments
Closed

ModuleNotFoundError: No module named 'encodings' #310

buxel opened this issue Apr 16, 2021 · 11 comments
Labels
invalid This issue/PR doesn't make sense. issue:wontfix This will not be worked on.

Comments

@buxel
Copy link

buxel commented Apr 16, 2021

Describe the bug
After installing heroic-1.5.7.x86_64.rpm on OpenSuse, it fails to launch any games. It looks like a python dependency is missing.

[cli] INFO: Logging in...
[Core] INFO: Trying to re-use existing login session...
[cli] INFO: Checking for updates...
[Core] INFO: Getting authentication token...
[cli] INFO: Launching Blowfish...
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Python path configuration:
  PYTHONHOME = (not set)
  PYTHONPATH = (not set)
  program name = 'python3'
  isolated = 0
  environment = 1
  user site = 1
  import site = 1
  sys._base_executable = '/usr/bin/python3'
  sys.base_prefix = '/usr'
  sys.base_exec_prefix = '/usr'
  sys.executable = '/usr/bin/python3'
  sys.prefix = '/usr'
  sys.exec_prefix = '/usr'
  sys.path = [
    '/usr/lib/python38.zip',
    '/usr/lib/python3.8',
    '/usr/lib/lib-dynload',
  ]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00007fa15b85c740 (most recent call first):
<no Python frame>

To Reproduce
Steps to reproduce the behavior:

  1. install .rpm version of heroic
  2. set it to use steam proton
  3. launch game

Desktop (please complete the following information):

  • OS: OpenSuse
  • Version Tumbleweed
  • Game: FTL
  • Wine/Proton version: Proton-6.3
@Nocccer
Copy link
Collaborator

Nocccer commented Apr 16, 2021

I searched a little bit. This seems not a problem with Heroic. Furthermore your Python configuration isn't correct, so it can't find the standard Python modules. At least PYTHONPATH or sys.path should point to your site-packages or script folder inside the python installation. This are the folders were python searches for modules.

E.g. my sys.path contains this paths, but yours not:
image

Maybe im wrong here and heroic or proton does set this paths by itself and can't find the site-package folders ?
Can you do the same as i did in the terminal and check if the sys.path contains the necessary paths. If not than search in the internet how to add them. Else it is really a problem with heroic/proton or what ever triggers python there.

@buxel
Copy link
Author

buxel commented Apr 16, 2021 via email

@Nocccer
Copy link
Collaborator

Nocccer commented Apr 16, 2021

I also have no experience with rpm packages. For me it looks like that the python configuration of the system is used to setup an enviroment where special dependencies are installed later (via pip). Also encodings is a standard module from python and will be copied from the local python to the virtual enviroment.

Can you please check if sys.path contains the necessary paths. If not your local python is broken and therefore also a python virtual enviroment.

You can also check if you can import encodings without errors:
image

If everything is fine, then it is a problem with heroic, legendary or proton. I don't think heroic is creating the enviroment, but not 100% sure. Could be proton instead.

@adityaruplaha adityaruplaha added issue:wontfix This will not be worked on. invalid This issue/PR doesn't make sense. labels Apr 16, 2021
@adityaruplaha
Copy link
Contributor

The OpenSUSE Python packages are incompatible with Legendary. Please use a compatible version. This is the error you're getting.

Closing as this is not a Heroic issue.

@buxel
Copy link
Author

buxel commented Apr 16, 2021

@Nocccer thanks for your help. i can import the module on my system like you did:
image

@adityaruplaha could you please elaborate? is it a conflict of module versions? shouldn't pip manage python modules independantly of the used distro? It would be great if you could give me some pointers.

@Nocccer
Copy link
Collaborator

Nocccer commented Apr 16, 2021

I checked legendary repository https://github.com/derrod/legendary.
You have the correct python version installed (3.8.x) but maybe the python module request is not installed ?

Heroic is just a gui around legendary and this is a problem of legendary, so maybe open your problem there?

@adityaruplaha
Copy link
Contributor

@buxel try to install Legendary standalone. If it works, please provide the output. In that case we'll have to look into what happened. If it doesn't, Legendary is incompatible, nothing we can do about it.

Also side note, never use pip to update global Python packages. Use your distros package manager.

@buxel
Copy link
Author

buxel commented Apr 17, 2021

It is an issue with legendary, as you suspected. Running it directly gives the same error. Thanks for checking, though! 👍

@Rudolf339
Copy link

I too faced this issue, the fix was to add the directory(ies) containing the missing module(s) to pythonpath.
In my case it was /usr/lib/python3.8/site-packages/feedparser/ and /usr/lib64/python3.8/.
You can find these with $ find /usr/ -name modulename.py

@flavioislima
Copy link
Member

Had the same issue after moving to Tumbleweed, so only to make it clear:
export PYTHONPATH=$PYTHONPATH:/usr/bin/python:/usr/lib/python3.8/site-packages:/usr/lib64/python3.8/ /opt/Heroic/heroic then using proton works.
Ofc its better to export this variable as a global one, so you don't need to call heroic from the terminal everytime.

@akien-mga
Copy link

akien-mga commented Jan 3, 2022

I'm testing with the Heroic 2.0.0 AppImage and getting the same issue on Mageia 9, RPM-based.

python3 -c "import encodings" works fine.

I don't have PYTHONPATH defined, and don't need to usually to run Python application (whether distro packages, pip installed, or in a venv).

My system Python is Python 3.9.8, but the log below refers to /opt/hostedtoolcache/Python/3.9.9/ which I guess is a virtual filesystem bundled into the legendary bin?

Example log from attempting to run Limbo with Proton Experimental from Steam:

Launch Command:           STEAM_COMPAT_CLIENT_INSTALL_PATH=/home/akien/.steam/steam STEAM_COMPAT_DATA_PATH='/home/akien/Games/Heroic/Prefixes/Limbo'   /tmp/.mount_HeroicPIJg7S/resources/app.asar.unpacked/build/bin/linux/legendary launch Hazelnut   --no-wine --wrapper "'/home/akien/.steam/steam/steamapps/common/Proton - Experimental/proton' run"   
        System Info:
        
  Heroic Version: 2.0.0 Roronoa Zoro
  Legendary Version:  0.20.22 Anticitizen One (hotfix #3)
  OS: Mageia KERNEL: 5.15.12-desktop-2.mga9 ARCH: x64
  CPU: Intel® Core™ i7-8705G @3.1 GOVERNOR: performance
  RAM: Total: 16.5 GB Available: 10.4 GB
  GRAPHICS: GPU0: HD Graphics 630  VRAM: 256MB DRIVER:  
  PROTOCOL: x11
  
        Game Settings: {
	"audioFix": false,
	"autoInstallDxvk": false,
	"autoSyncSaves": false,
	"enableEsync": false,
	"enableFSR": false,
	"enableFsync": false,
	"maxSharpness": 2,
	"enableResizableBar": false,
	"nvidiaPrime": false,
	"offlineMode": false,
	"otherOptions": "",
	"savesPath": "/home/akien/Games/Heroic/Limbo/save_game/",
	"showFps": false,
	"showMangohud": false,
	"targetExe": "",
	"useGameMode": false,
	"wineCrossoverBottle": "Heroic",
	"winePrefix": "~/Games/Heroic/Prefixes/Limbo",
	"wineVersion": {
		"bin": "'/home/akien/.steam/steam/steamapps/common/Proton - Experimental/proton'",
		"name": "Proton - Proton - Experimental"
	}
}

        Legendary Log:
        [cli] INFO: Logging in...
[Core] INFO: Trying to re-use existing login session...
[cli] INFO: Checking for updates...
[Core] INFO: Getting authentication token...
[cli] INFO: Launching Hazelnut...
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Python path configuration:
  PYTHONHOME = (not set)
  PYTHONPATH = (not set)
  program name = 'python3'
  isolated = 0
  environment = 1
  user site = 1
  import site = 1
  sys._base_executable = '/usr/bin/python3'
  sys.base_prefix = '/opt/hostedtoolcache/Python/3.9.9/x64'
  sys.base_exec_prefix = '/opt/hostedtoolcache/Python/3.9.9/x64'
  sys.platlibdir = 'lib'
  sys.executable = '/usr/bin/python3'
  sys.prefix = '/opt/hostedtoolcache/Python/3.9.9/x64'
  sys.exec_prefix = '/opt/hostedtoolcache/Python/3.9.9/x64'
  sys.path = [
    '/opt/hostedtoolcache/Python/3.9.9/x64/lib/python39.zip',
    '/opt/hostedtoolcache/Python/3.9.9/x64/lib/python3.9',
    '/opt/hostedtoolcache/Python/3.9.9/x64/lib/lib-dynload',
  ]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00007fcb2f52f740 (most recent call first):
<no Python frame>

Edit: I tested two other legendary versions and they work well:

So the problem seems to be specific to the bundled version in the Heroic distribution. I tested both the AppImage and the .tar.xz portable build and both have the same issue when using resources/app.asar.unpacked/build/bin/linux/legendary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This issue/PR doesn't make sense. issue:wontfix This will not be worked on.
Projects
None yet
Development

No branches or pull requests

6 participants