Reputation: 3426
I am creating a Windows EXE using cx_freeze, Python3 and the Scipy installation from lfd.uci.edu. Upon running the exe, I receive the error: ImportError: cannot import name nonlin
.
The Scipy file line this references, in site-packages\scipy\optimize_root.py: from . import nonlin
.
I can load a console with Python, and successfully run import scipy.optimize.nonlin
.
Adding scipy.optimize.nonlin to my setup.py includes doesn't solve the problem.
nonlin.py is located in the optimize directory in my scipy install, and its corresponding location as a compiled file in the library file cx_freeze generates.
Upvotes: 4
Views: 996
Reputation: 171
The reason I'm backing to this thread is that recently a friend of mine asked for help around this issue.
Given that, here is the same solution approach: Circular dependency while executing cx_Freeze result
In the setup script, just add the package failure references as below:
packages = ["scipy.optimize", "scipy.integrate", ...]
Upvotes: 1
Reputation: 11
I had the same trouble, but nonlin was imported in "/scipy/optimize/init.py" file. It is marked as "# Deprecated namespaces, to be removed in v2.0.0". You can just comment the string in file, where import nonlin is. It worked for me.
Upvotes: 1
Reputation: 6320
I've had a lot of issues with cx_Freeze and Scipy. The only thing I really found to work was to either add the missing module to the "includes" option or to manually add the needed files to the "include_files" option.
This link helped me with interpolation. https://bitbucket.org/anthony_tuininga/cx_freeze/issue/43/import-errors-when-using-cx_freeze-with
{"includes": ["scipy.special._ufuncs_cxx"],
"include_files": [(python_exe_path+"/Lib/site-packages/scipy/sparse/sparsetools/_csr.pyd",
"_csr.pyd") ],
}
This isn't exactly the same problem for you, but it may help you find the needed files to include them properly. "includes" didn't work for you, so you could manually add it with "include_files" or "zip_includes" depending on where it is searching for your file.
{"zip-include": (python_exe_path+"/Lib/site-packages/scipy/optimize/nonlin.py,
"scipy/optimize/nonlin.py")}
Upvotes: 0