Pay*_*m30 3 matlab matlab-engine pyinstaller python-3.x d3.js
我已经使用pyqt. 从 IDE 运行时,.py 文件运行良好。但是,当使用以下命令运行 .exe 文件时:
pyinstaller --name="Myapp" --windowed --onefile main.py
Run Code Online (Sandbox Code Playgroud)
我得到一个 .exe 文件。当我尝试运行它时它说
Failed to execure script main
Run Code Online (Sandbox Code Playgroud)
我又试了一次,但这次是:
pyinstaller main.py
Run Code Online (Sandbox Code Playgroud)
它确实生成了一个名为 的文件main夹dist。我main.exe在命令行中运行并得到:
ImportError: No module named 'mlarray'
Run Code Online (Sandbox Code Playgroud)
我去了matlab我已经安装的Python库\Python\Python36\Lib\site-packages\matlab并进行了mlarray.py如下更改:
from _internal.mlarray_sequence import _MLArrayMetaClass
Run Code Online (Sandbox Code Playgroud)
到:
from matlab._internal.mlarray_sequence import _MLArrayMetaClass
Run Code Online (Sandbox Code Playgroud)
我什至将__init__.py: 更改为:
from mlarray import double, single, uint8, int8, uint16, \
int16, uint32, int32, uint64, int64, logical
from mlexceptions import ShapeError as ShapeError
from mlexceptions import SizeError as SizeError
Run Code Online (Sandbox Code Playgroud)
到:
from matlab.mlarray import double, single, uint8, int8, uint16, \
int16, uint32, int32, uint64, int64, logical
from matlab.mlexceptions import ShapeError as ShapeError
from matlab.mlexceptions import SizeError as SizeError
Run Code Online (Sandbox Code Playgroud)
最后我Python\Python36\Lib\site-packages\matlab\_internal\mlarray_sequence.py
从:
from _internal.mlarray_utils import _get_strides, _get_size, \
_normalize_size, _get_mlsize, _reshape
Run Code Online (Sandbox Code Playgroud)
到:
from matlab._internal.mlarray_utils import _get_strides, _get_size, \
_normalize_size, _get_mlsize, _reshape
Run Code Online (Sandbox Code Playgroud)
保存所有工作并再次尝试执行 pyinstaller。
pyinstaller main.py
Run Code Online (Sandbox Code Playgroud)
这次我收到以下错误:
File "site-packages\matlab\engine\__init__.py", line 62, in <module>
OSError: Please reinstall MATLAB Engine for Python or contact MathWorks Technical Support for assistance: [Errno 2] No such file or directory: 'C:\\pmafgx_das\\das2\\main\\ReleaserQt\\dist\\main\\matlab\\engine\\_arch.txt'
[2028] Failed to execute script main
Run Code Online (Sandbox Code Playgroud)
这变得非常令人沮丧,我不知道还能做什么。如果您有见解,如果您能帮助我,我将不胜感激。
首先删除对 的更改matlab。
然后创建一个目录结构和hook-matlab.py文件,如下树所示:
- script_to_compile.py # This is the python file you run pyinstaller on
- hooks # DIR
- hook-matlab.py
Run Code Online (Sandbox Code Playgroud)
以及里面hook-matlab.py:
from PyInstaller.utils.hooks import collect_all
datas, binaries, hiddenimports = collect_all('matlab')
Run Code Online (Sandbox Code Playgroud)
然后使用额外的选项进行构建--additional-hooks-dir=hooks。
| 归档时间: |
|
| 查看次数: |
779 次 |
| 最近记录: |