3

Okay so I compiled my python project into an executable and it worked on my computer but I sent it to a couple of friends to test and they all got this error. I have never seen an error like this before. I used Nuitka to compile the code.

Traceback (most recent call last):   File "C:\Python39\lib\inspect.py", line 35, in <module>
import ast   File "C:\Python39\lib\ast.py", line 29, in <module>
from contextlib import contextmanager, nullcontext   File "C:\Python39\lib\contextlib.py", line 4, in <module>
import _collections_abc   File "C:\Python39\lib_collections_abc.py", line 416, in <module>
class _CallableGenericAlias(GenericAlias): TypeError: type 'types.GenericAlias' is not an acceptable base type`
CheemaOTB
  • 39
  • 1
  • 3
  • This sounds like an issue with mixing Python versions. – user2357112 Mar 21 '21 at 03:55
  • But with Nuitka it creates a python 3.9 dll so shouldn't the executable use that then? Also, how can I make it so the user doesn't have to install the python libraries I used when trying to run the executable? – CheemaOTB Mar 21 '21 at 06:18
  • I guess you compiled with an earlier python version that your friends. I just had this same error to discover at the end that I compiled with a 3.9.1 (the latest at that moment) and I used it later with a docker based on 3.9.16. Try and recompile with a newer 3.9 version. – Alessandro Dentella Jan 16 '23 at 22:44

1 Answers1

2

I know I'm very late for this but it might help someone in the future,

Caution: This solution involves messing around with source files and I was comfortable with that because I was using it in an isolated conda environment. Make sure you understand what you're doing before implementing it because clearly I DON'T.

I applied the solution pointed out in this post and it somehow solved the issue for me.

Basically I went into the source _collections_abc.py source file and swapped the variable GenericAlias in _CallableGenericAlias(GenericAlias) to _CallableGenericAlias(GenericAlias) which was declared at the beginning as GenericAlias = type(list[int]) to _CallableGenericAlias(GenericAlias) to _CallableGenericAlias(list[int])

Again, use with caution, because I also don't fully understand what's going on.

Original post found here

Albas
  • 53
  • 1
  • 6
  • Similar situation, probably bad install of Python in the conda environment. Happened to me after creating a new conda environment using mamba: `mamba create -n ... python=3.9` with resulting Python 3.9.1. The changes in the answer do fix the issue as far as I can see. – dtasev Dec 15 '22 at 15:23