Autor Wątek:  Python error on Linux: IndexError: string index out of range  (Przeczytany 2747 razy)

0 użytkowników i 1 Gość przegląda ten wątek.

Offline guih48

  • Wiadomości: 4
    • Zobacz profil
  • Otrzymane polubienia: 15
Python error on Linux: IndexError: string index out of range
« dnia: 10 Sierpnia 2023, 15:13:34 »
Hello everyone!

I've just compiled Maszyna (eu07_2022-04-02) on GNU/Linux, but it crashes on start and gives the following output:

   ...
Created texture object for "textures/fx/smoke"
Loading texture data from "textures/fx/smoke"
Created texture object for "textures/fx/headlights"
Loading texture data from "textures/fx/headlights"
...gfx data pre-loading done
init viewport: 1920 x 1080
envmap enabled
picking objects created
Gfx Renderer: setup complete
available audio devices:
OpenAL Soft
Audio Renderer: OpenAL Soft OpenAL Version: 1.1
Supported extensions: ALC_ENUMERATE_ALL_EXT ALC_ENUMERATION_EXT ALC_EXT_CAPTURE ALC_EXT_DEDICATED ALC_EXT_disconnect ALC_EXT_EFX ALC_EXT_thread_local_context ALC_SOFT_device_clock ALC_SOFT_HRTF ALC_SOFT_loopback ALC_SOFT_loopback_bformat ALC_SOFT_output_limiter ALC_SOFT_output_mode ALC_SOFT_pause_device ALC_SOFT_reopen_device
Traceback (most recent call last):
  File "linuxpython64/lib/python2.7/site.py", line 190, in <module>
    main()
  File "linuxpython64/lib/python2.7/site.py", line 18, in main
    rewrite_standard_library_sys_path()
  File "linuxpython64/lib/python2.7/site.py", line 92, in rewrite_standard_library_sys_path
    sys.path[at] = map_path(path, base_exe, exe_dir, exec_prefix, base_prefix, prefix, base_exec)
  File "linuxpython64/lib/python2.7/site.py", line 124, in map_path
    if path_starts_with(path, exe_dir):
  File "linuxpython64/lib/python2.7/site.py", line 136, in path_starts_with
    return directory.startswith(value if value[-1] == sep else value + sep)
IndexError: string index out of range


Anyone can help, what can I do about it?

Offline Milek7

  • Administrator
  • Wiadomości: 1047
    • Zobacz profil
  • Otrzymane polubienia: 903
Odp: Python error on Linux: IndexError: string index out of range
« Odpowiedź #1 dnia: 10 Sierpnia 2023, 16:38:27 »
Side note: development branch is currently at https://github.com/Milek7/maszyna/tree/sim. Main repository is not always kept up to date, sorry about that. I updated it now.

Back to topic: I'm not sure, I didn't seen this error before. Did you setup python directories using virtualenv?

Offline guih48

  • Wiadomości: 4
    • Zobacz profil
  • Otrzymane polubienia: 15
Odp: Python error on Linux: IndexError: string index out of range
« Odpowiedź #2 dnia: 10 Sierpnia 2023, 18:28:03 »
Cytuj
Side note: development branch is currently at https://github.com/Milek7/maszyna/tree/sim. Main repository is not always kept up to date, sorry about that. I updated it now.
Back to topic: I'm not sure, I didn't seen this error before. Did you setup python directories using virtualenv?

The latest version also does the same :(

Offline Czarodziej

  • Wiadomości: 350
    • Zobacz profil
  • Otrzymane polubienia: 93
Odp: Python error on Linux: IndexError: string index out of range
« Odpowiedź #3 dnia: 11 Sierpnia 2023, 12:23:01 »
Mac/arm64 here, Milek's branch builds fine, I'm not getting your error.
What I've done to get python working is that I used pyenv to install 2.7, then I installed Pillow using:
pip install --global-option=build_ext --global-option="-L/opt/homebrew/Cellar/zlib/1.2.13/lib" --global-option="-I/opt/homebrew/Cellar/zlib/1.2.13/include"  Pillow==5.0.0(On Linux you won't need global options, just be sure to have proper headers installed)
Then I copied whole ~/.pyenv/versions/2.7.18 to Maszyna's folder and called it macpython64.

Offline joey

  • Deweloper
  • Wiadomości: 422
  • the Invisible Man
    • Zobacz profil
  • Otrzymane polubienia: 209
Odp: Python error on Linux: IndexError: string index out of range
« Odpowiedź #4 dnia: 17 Sierpnia 2023, 17:20:41 »
I seem to have a pretty much the same error (the only difference being the line numbers in the console output) when trying to use the Linux binary on Debian 11.
I used symlinks to files and directories on an NTFS partition to make the files accessible on both Linux and Windows and also not to unnecessarily double the disk space used by Maszyna.

I have installed the following packages beforehand:
freeglut3 libpython2.7 libpng16-16 libopenal1 libsndfile1 libluajit-5.1-2 libserialport0 virtualenv
As Python 2 has been made obsolete, virtualenv creates Python 3 venvs, so to create a Python 2.7 venv I typed:
$ virtualenv --python=/usr/bin/python2.7 linuxpython64which gave me the following output:created virtual environment CPython2.7.18.final.0-64 in 280ms
  creator CPython2Posix(dest=***/M2207/linuxpython64, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/***/.local/share/virtualenv)
    added seed packages: pip==20.3.4, pkg_resources==0.0.0, setuptools==44.1.1, wheel==0.34.2
  activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator

I then cd'd into the linuxpython64 directory, and ran:$ source bin/activate
$ pip install pillow
which gave me the following output:DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Collecting pillow
  Using cached Pillow-6.2.2-cp27-cp27mu-manylinux1_x86_64.whl (2.1 MB)
Installing collected packages: pillow
Successfully installed pillow-6.2.2

I then left the venv:
$ deactivatecd'd .. and tried to run the binary from Azure:./eu07_2023-08-08which crashed with log.txt ending at OpenAL stage, and the dreaded lines following it in the console only:Traceback (most recent call last):
  File "linuxpython64/lib/python2.7/site.py", line 164, in <module>
    main()
  File "linuxpython64/lib/python2.7/site.py", line 17, in main
    rewrite_standard_library_sys_path()
  File "linuxpython64/lib/python2.7/site.py", line 87, in rewrite_standard_library_sys_path
    sys.path[at] = map_path(path, base_exe, exe_dir, exec_prefix, base_prefix, prefix, base_exec)
  File "linuxpython64/lib/python2.7/site.py", line 119, in map_path
    if path_starts_with(path, exe_dir):
  File "linuxpython64/lib/python2.7/site.py", line 131, in path_starts_with
    return directory.startswith(value if value[-1] == sep else value + sep)
IndexError: string index out of range

Just in case something's missing, the output of ls in the root directory:
crashdumps               eu07_input-mouse.ini  logs               scripts
data                     eu07_input-uart.ini   log.txt            shaders
dynamic                  fonts                 models             sounds
en-readme.html           imgui.ini             przepisy_kolejowe  ssleay32.dll
eu07_2023-08-08          inne                  readme.html        starter
eu07.exe                 lang                  rev.txt            Starter.exe
eu07.ini                 libeay32.dll          scenery            textures
eu07_input-keyboard.ini  linuxpython64         screenshots