py2exe import numpy and scipy - python

I used py2exe to build an exe of a program that uses scipy and numpy and I get the next error in the log file when I tried to run the program.
Traceback (most recent call last):
File "GLP2-e Admin.pyw", line 24, in <module>
File "C:\Python34\lib\site-packages\scipy\ndimage\__init__.py", line 161, in <module>
from .filters import *
File "C:\Python34\lib\site-packages\scipy\ndimage\filters.py", line 37, in <module>
from scipy.misc import doccer
File "C:\Python34\lib\site-packages\scipy\misc\__init__.py", line 51, in <module>
from scipy.special import comb, factorial, factorial2, factorialk
File "C:\Python34\lib\site-packages\scipy\special\__init__.py", line 629, in <module>
from .basic import *
File "C:\Python34\lib\site-packages\scipy\special\basic.py", line 18, in <module>
from . import orthogonal
File "C:\Python34\lib\site-packages\scipy\special\orthogonal.py", line 101, in <module>
from scipy import linalg
File "C:\Python34\lib\site-packages\scipy\linalg\__init__.py", line 190, in <module>
from ._decomp_update import *
File "<loader>", line 10, in <module>
File "<loader>", line 8, in __load
ImportError: (No module named 'scipy.linalg.cython_blas') 'Y:\\Factory\\GLP2-e Admin (Todos los archivos)\\Compilaciones\\VersiĆ³n 2.1\\dist\\scipy.linalg._decomp_update.pyd'
I have tried some thing like put my setup.py file like this:
options ={
'py2exe': {
'bundle_files' : 3,
r'includes':[r'scipy.sparse.csgraph._validation',
r'scipy.special._ufuncs_cxx',],
'packages' : ['encodings'],
}
},
But it doesn't work and I still get that error.
I don't know what to do to solve this issue...
Hope you can help me.
Thanks.

I have been solve the issue adding in the "includes" section of my setup.py all the files that the log file return me as missing. After 7 files, the program run without any error.

Related

Thonny py5-mode Error when running a code

I just tried to use py5 in thonny, but everytime i have the py5 mode on and try to run a code i get a bunch of error messeges, i dont really know what they mean so maybe somebody can help me out ?
thanks in advance
This is the error im always getting
Traceback (most recent call last):
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\py5_tools\tools\run_sketch.py", line 52, in <module>
main()
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\py5_tools\tools\run_sketch.py", line 44, in main
imported.run_code(
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\py5_tools\imported.py", line 135, in run_code
_run_code(
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\py5_tools\imported.py", line 259, in _run_code
_run_sketch(sketch_path, classpath, exit_if_error)
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\py5_tools\imported.py", line 196, in _run_sketch
import py5
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\py5\__init__.py", line 84, in <module>
from py5_tools.magics import load_ipython_extension # noqa
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\py5_tools\magics\__init__.py", line 22, in <module>
from .drawing import DrawingMagics, DXFDrawingMagic
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\py5_tools\magics\drawing.py", line 27, in <module>
from IPython.display import display, SVG, Image
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\IPython\__init__.py", line 51, in <module>
from .core.application import Application
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\IPython\core\application.py", line 26, in <module>
from IPython.core import release, crashhandler
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\IPython\core\crashhandler.py", line 27, in <module>
from IPython.core import ultratb
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\IPython\core\ultratb.py", line 101, in <module>
import stack_data
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\stack_data\__init__.py", line 1, in <module>
from .core import Source, FrameInfo, markers_from_ranges, Options, LINE_GAP, Line, Variable, RangeInLine, \
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\stack_data\core.py", line 19, in <module>
from stack_data.utils import (
File "C:\Users\schwe\AppData\Roaming\Thonny\plugins\Python310\site-packages\stack_data\utils.py", line 11, in <module>
from asttokens import ASTText
ImportError: cannot import name 'ASTText' from 'asttokens' (C:\Users\schwe\AppData\Local\Programs\Thonny\lib\site-packages\asttokens\__init__.py)
I received a response from the py5 developer via Github. They also provided an explanation but it goes over my head, something about "The Python library asttokens is used for parsing syntax trees and syntax highlighting. It is not used by py5 but it might be used by Jupyter Notebook and/or JupyterLab.". They also provided a solution here:
enter link description here

Bug when try to use gtts -

I met this problem when running program, this also happened when I tried pyttsx3 . Anyone know this problem. I was looking for some solution but none of it works.
Traceback (most recent call last):
File "/Users/macbookpro/Documents/python/generate_words.py", line 80, in <module>
main()
File "/Users/macbookpro/Documents/python/generate_words.py", line 16, in main
answer_part()
File "/Users/macbookpro/Documents/python/generate_words.py", line 51, in answer_part
translate(w)
File "/Users/macbookpro/Documents/python/generate_words.py", line 57, in translate
playsound.playsound('welcome.mp3')
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/playsound.py", line 55, in _playsoundOSX
from AppKit import NSSound
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/AppKit/__init__.py", line 10, in <module>
import Foundation
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/Foundation/__init__.py", line 9, in <module>
import CoreFoundation
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/CoreFoundation/__init__.py", line 9, in <module>
import objc
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/objc/__init__.py", line 6, in <module>
from . import _objc
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/objc/_objc.cpython-310-darwin.so, 2): Symbol not found: _FSPathMakeRef
Referenced from: /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/objc/_objc.cpython-310-darwin.so
Expected in: flat namespace
in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/objc/_objc.cpython-310-darwin.so

Theano tensor import error

I have been trying to import theano.tensor in my code.
I have used theano.tensor before. All of my previous code importing theano.tensor works perfectly in my machine. Now I am trying to write another script importing the tensor from theano and I am getting the following exception.
Traceback (most recent call last):
File "code.py", line 2, in <module>
import theano.tensor as T
File "/anaconda3/lib/python3.5/site-packages/theano/__init__.py", line 52, in <module>
from theano.gof import (
File "/anaconda3/lib/python3.5/site-packages/theano/gof/__init__.py", line 56, in <module>
from theano.gof.opt import (
File "/anaconda3/lib/python3.5/site-packages/theano/gof/opt.py", line 11, in <module>
import pdb
File "/anaconda3/lib/python3.5/pdb.py", line 75, in <module>
import code
File "/localtmp/saikat/CovInfo/Closure/code.py", line 2, in <module>
import theano.tensor as T
File "/anaconda3/lib/python3.5/site-packages/theano/tensor/__init__.py", line 6, in <module>
from theano.tensor.basic import *
File "/anaconda3/lib/python3.5/site-packages/theano/tensor/basic.py", line 17, in <module>
from theano.tensor import elemwise
File "/anaconda3/lib/python3.5/site-packages/theano/tensor/elemwise.py", line 13, in <module>
from theano import scalar
File "/anaconda3/lib/python3.5/site-packages/theano/scalar/__init__.py", line 2, in <module>
from .basic import *
File "/anaconda3/lib/python3.5/site-packages/theano/scalar/basic.py", line 25, in <module>
from theano import gof, printing
File "/anaconda3/lib/python3.5/site-packages/theano/printing.py", line 22, in <module>
from theano.compile import Function, debugmode, SharedVariable
File "/anaconda3/lib/python3.5/site-packages/theano/compile/__init__.py", line 9, in <module>
from theano.compile.function_module import *
File "/anaconda3/lib/python3.5/site-packages/theano/compile/function_module.py", line 22, in <module>
import theano.compile.mode
File "/anaconda3/lib/python3.5/site-packages/theano/compile/mode.py", line 77, in <module>
OPT_NONE = gof.Query(include=[], exclude=exclude)
AttributeError: module 'theano.gof' has no attribute 'Query'
I cannot find any plausible reason for this exception.
I guess i got your problem. See in the error log:
File "/anaconda3/lib/python3.5/pdb.py", line 75, in <module>
import code
I believe there is another script called code.py in Theano which gets called from pdb.py when python interpreter executes your script which is also named as code.py. I am guessing python interpreter is mixing up these two scripts and executing the wrong one! You can change the filename and check whether the error disappear or not.

py2exe with wxpython and wxpython DLL load failed

I want to use py2exe to pack a python file.
from distutils.core import setup
from glob import glob
import scipy
import numpy
import py2exe
import matplotlib
import wx
import sys
setup(
windows=["practice.py"],
options={"py2exe":
{"dll_excludes":["libiomp5md.dll",
"OLEAUT32.dll",
"USER32.dll",
"IMM32.dll",
"ole32.dll",
"MSVCP90.dll",
"SHELL32.dll",
"RPCRT4.dll",
"COMDLG32.dll",
"WSOCK32.dll",
"COMCTL32.dll",
"ADVAPI32.dll",
"WS2_32.dll",
"WINSPOOL.DRV",
"GDI32.dll",
"WINMM.dll",
"KERNEL32.dll",
"msvcm90.dll",
"msvcp90.dll",
"msvcr90.dll",
'libgdk-win32-2.0-0.dll',
'libgobject-2.0-0.dll'],
"includes" : [ "matplotlib.backends",
"matplotlib.backends.backend_qt4agg",
"pylab",
"numpy",
"wx",
"scipy",
"matplotlib.backends.backend_tkagg"],
'excludes':['_gtkagg',
'_tkagg',
'_agg2',
'_cairo',
'_cocoaagg',
'_fltkagg',
'_gtk',
'_gtkcairo']
}
},
data_files=matplotlib.get_py2exe_datafiles()
)
However,when I open the .exe, it reported as following
Traceback (most recent call last):
File "practice.py", line 1, in <module>
File "matplotlib\__init__.pyc", line 180, in <module>
File "matplotlib\cbook.pyc", line 33, in <module>
File "numpy\__init__.pyc", line 168, in <module>
File "numpy\add_newdocs.pyc", line 13, in <module>
File "numpy\lib\__init__.pyc", line 18, in <module>
File "numpy\lib\polynomial.pyc", line 19, in <module>
File "numpy\linalg\__init__.pyc", line 50, in <module>
File "numpy\linalg\linalg.pyc", line 29, in <module>
File "numpy\linalg\lapack_lite.pyc", line 12, in <module>
File "numpy\linalg\lapack_lite.pyc", line 10, in __load
ImportError: DLL load failed: can't find specific modulus.
64bit windows8 python2.7.9
I have searched in Stackoverflow and find some answers, however, it doesn't work.
Is your numpy installation ok?
"numpy\linalg\linalg.pyc", line 29 is trying to load
from numpy.linalg import lapack_lite, _umath_linalg
In my installation, I have lapack_lite.pyd and _umath_linalg.pyd there.
But it looks like your numpy is somehow expecting lapack_lite.pyc. I do not know why they are different but perhaps re-installing the numpy will help?
Numpy usually behaves very well with py2exe.

Cannot import name mlab

I've encountered a very strange error when trying to Import mayavi. A few minutes ago it worked like a charm, but now there's something going wrong and I've no clue why.
I start python from the terminal and then I type:
from mayavi import mlab
The error I get:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/mayavi/mlab.py", line 27, in <module>
from mayavi.tools.camera import view, roll, yaw, pitch, move
File "/usr/lib/python2.7/dist-packages/mayavi/tools/camera.py", line 23, in <module>
from engine_manager import get_engine
File "/usr/lib/python2.7/dist-packages/mayavi/tools/engine_manager.py", line 14, in <module>
from mayavi.core.engine import Engine
File "/usr/lib/python2.7/dist-packages/mayavi/core/engine.py", line 28, in <module>
from mayavi.core.scene import Scene
File "/usr/lib/python2.7/dist-packages/mayavi/core/scene.py", line 15, in <module>
from mayavi.core.source import Source
File "/usr/lib/python2.7/dist-packages/mayavi/core/source.py", line 19, in <module>
from mayavi.core.module_manager import ModuleManager
File "/usr/lib/python2.7/dist-packages/mayavi/core/module_manager.py", line 19, in <module>
from mayavi.core.lut_manager import LUTManager
File "/usr/lib/python2.7/dist-packages/mayavi/core/lut_manager.py", line 10, in <module>
import subprocess
File "/usr/lib/python2.7/subprocess.py", line 432, in <module>
import pickle
File "pickle.py", line 4, in <module>
from mayavi import mlab
ImportError: cannot import name mlab
What's wrong with Python?
You have a local file named pickle.py; this is being imported instead of the pickle module. This module then tries to import mlab before that module itself has completed importing in a circular import dependency:
File "/usr/lib/python2.7/subprocess.py", line 432, in <module>
import pickle
File "pickle.py", line 4, in <module>
from mayavi import mlab
Note how subprocess tries to import pickle and finds your file instead (the path is relative instead of a full path inside /usr/lib/python2.7/.
Rename pickle.py to something else, you are masking the standard library here.

Categories

Resources