3

The default Python version for MSYS2 seems to be 3.8. I need to use 3.7 at the moment because I have to use PyInstaller and it is not currently compatible with 3.8 in MSYS2. I can download the earlier version of Python from http://repo.msys2.org/ and install it using pacman. With a fresh install of MSYS2 I run the following commands:

pacman -S glib2-devel
pacman -U python-3.7.4-1-x86_64.pkg.tar.xz
pacman -S python-pip
pacman -S python-setuptools

If I try to run a python script I am met with an error:

  File "setup.py", line 15, in <module>
    from setuptools import setup
ModuleNotFoundError: No module named 'setuptools'

This is due to the fact that everything installed after Python is actually installing in the default Python 3.8 location rather than 3.7:

C:\msys64\usr\lib\python3.8\site-packages

If I copy and paste the contents of site-packages into Python 3.7 and then try running a script I get the error:

  File "setup.py", line 15, in <module>
    from setuptools import setup
  File "/usr/lib/python3.7/site-packages/setuptools/__init__.py", line 19, in <module>
    from setuptools.dist import Distribution
  File "/usr/lib/python3.7/site-packages/setuptools/dist.py", line 34, in <module>
    from setuptools import windows_support
  File "/usr/lib/python3.7/site-packages/setuptools/windows_support.py", line 2, in <module>
    import ctypes
  File "/usr/lib/python3.7/ctypes/__init__.py", line 7, in <module>
    from _ctypes import Union, Structure, Array
ImportError: No such file or directory

Which is supposed to be resolved via libffi, which was installed prior to Python, but likely does not go to a location that 3.7 can recognize?

Is there a way to set a specific version of Python as the default in MSYS2? Perhaps a path that can be set in the .bashrc file? I tried to set PYTHONPATH in there to Python 3.7 but it didn't make a difference as to where the packages ended up being installed to.

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
Leigh K
  • 561
  • 6
  • 20

2 Answers2

1

Go to the following URL...

https://repo.msys2.org/msys/x86_64/

Look for the version of the package you need and download it. Use

pacman -U pkgname

To install it...

The reason I know this is because gcc11 on MSYS is non-functional... it produces programs which crash and say "During startup your program exited with code..." mentioned here:

During startup program exited with code 0xc0000139

The only workaround is to downgrade to the previous compiler which does work or use clang, which was not an option for me.

HolyBlackCat
  • 78,603
  • 9
  • 131
  • 207
greg.casamento
  • 353
  • 2
  • 6
  • I highly doubt MSYS2 would've released an obviously broken compiler. You might have incompatible dlls in PATH and/or `C:\Windows`. Try running [`ntldd -R my_program.exe`](https://github.com/LRN/ntldd) and looking at the dlls it prints. If any of them exist in `C:\msys64\mingw64\bin`, but are loaded from elsewhere, that's your problem. – HolyBlackCat Mar 03 '22 at 06:03
0

Trying to use an old version of Python is probably possible, but I think it will be very difficult. You would need to make sure all the other installed packages are compatible.

I am using PyInstaller with Python 3.8 in MSYS2 without issues. I would recommend trying to work through any issues with that, instead of trying to use older versions of packages.

Dan Yeaw
  • 741
  • 8
  • 16