Heroic-Games-Launcher / HeroicGamesLauncher

A games launcher for GOG, Amazon and Epic Games for Linux, Windows and macOS.
https://heroicgameslauncher.com
GNU General Public License v3.0
7.94k stars 420 forks source link

ModuleNotFoundError: No module named 'encodings' #310

Closed buxel closed 3 years ago

buxel commented 3 years ago

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):

Nocccer commented 3 years ago

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 commented 3 years ago

I expected all dependencies to be managed by the package manager when installing the .rpm. Having to install a global package afterwards seems unusual,  that's why I suspected some dependency might be missing in the package setup and created this issue. The system setup is quite new and clean and I did not meddle with any python configuration. How is the environment set up for heroic? I have never done packaging myself but I guess you must somehow be shipping other python packages as well. Couldn't it be included there?  Otherwise any other system which does not have this package installed by default (or coincidence) will run into this issue.

Nocccer commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

@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 commented 3 years ago

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 commented 3 years ago

@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 commented 3 years ago

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

Rudolf339 commented 3 years ago

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 commented 3 years ago

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 commented 2 years ago

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 Could not find platform dependent libraries Consider setting $PYTHONHOME to [:] 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): ```

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.