Kubson
Kubson

Reputation: 215

PyInstaller: ImportError: cannot import name 'ccompiler' from partially initialized module 'numpy.distutils'

After freezing my program with PyInstaller, I encountered following error while trying to run the executable:

ModuleNotFoundError: No module named 'numpy.distutils'

After adding numpy.distutils to hidden imports, I am getting a new error:

ImportError: cannot import name 'ccompiler' from partially initialized module 'numpy.distutils' (most likely due to a circular import)

with which I don't know what to do. Those are imports from my code :

import pyodbc
import numpy as np
import fiona
import pandas as pd
import geopandas as gpd
import rasterio
from rasterio import features
from rasterstats import zonal_stats
import PySimpleGUI as sg

Upvotes: 4

Views: 1484

Answers (2)

Grzegorz Bokota
Grzegorz Bokota

Reputation: 1804

Just update to Pyinstaller 4.8. They fix this error in this release.

Upvotes: 0

neroop
neroop

Reputation: 21

Try to collect all submodules of Numpy

--collect-submodules numpy

then, you may get a new error or others

ModuleNotFoundError: No module named 'distutils.unixccompiler'

Adding them to hidden imports

--hidden-import distutils.unixccompiler

Upvotes: 2

Related Questions