Scipy and CX_freeze - Scipy import error: you cannot import scipy while in the scipy source directory

I am having trouble compiling exe when using cx_freeze and scipy. In particular, my script uses

from scipy.interpolate import griddata 

The build process seems to have completed successfully, however, when I try to run the compiled exe, I get the following message.

 Traceback (most recent call last): File "C:\Python27\lib\site-packages\cx_Freeze\initscripts\Console.py", line 27, in <module> exec(code, m.__dict__) File "gis_helper.py", line 13, in <module> File "C:\Python27\lib\site-packages\scipy\__init__.py", line 103, in <module> raise ImportError(msg) ImportError: Error importing scipy: you cannot import scipy while being in scipy source directory; please exit the scipy source tree first, and relaunch your python intepreter. 

After viewing the scipy \ _init __. Py file, the following exists:

 if __SCIPY_SETUP__: import sys as _sys _sys.stderr.write('Running from scipy source directory.\n') del _sys else: try: from scipy.__config__ import show as show_config except ImportError: msg = """Error importing scipy: you cannot import scipy while being in scipy source directory; please exit the scipy source tree first, and relaunch your python intepreter.""" raise ImportError(msg) 

I'm not quite sure that this is a problem, although it seems that erros is throwing because there is a problem with the scipy configuration file. It may not be included in the build process. I am new and hope that someone more experienced in building an assembly using cxfreeze can shed some light on this.

By the way, the scipy used was installed from binary files here .

+6
source share
2 answers

I had the same problem. I added this code to setup.py generated by cx_freeze:

 import scipy includefiles_list=[] scipy_path = dirname(scipy.__file__) includefiles_list.append(scipy_path) 

Then includefiles_list used as part of the build_exe parameter:

 build_options = dict(packages=[], include_files=includefiles_list) setup(name="foo", options=dict(build_exe=build_options)) 
+10
source

I add the same problem and solve it using the fepzzz method and including some missing packages:

 additional_mods = ['numpy.matlib', 'multiprocessing.process'] includefiles = [(r'C:\Anaconda3\Lib\site-packages\scipy')] setup(xxx, options={'build_exe': {'includes': additional_mods, 'include_files': includefiles}}) 

And using version 5.0.2 of the cx-Freeze package, which solved the error when importing multiprocessing.process

0
source

All Articles