[英]Compile a Python project Windows
I have the following directory structure to my python project: 我的python项目具有以下目录结构:
eplusplus/
|
|
----__main__.py
----model/
----exception/
----controller/
----view/
The directories: model, exception, controller and view each one has its __init__.py
. 目录:模型,异常,控制器和视图每个都有其
__init__.py
。 When I run the program at my machine I always use this following command: py -m eplusplus
. 当我在机器上运行程序时,我总是使用以下命令:
py -m eplusplus
。 But when I tried to use py2exe or pytinstaller the the points to: permission denied
. 但是,当我尝试使用py2exe或pytinstaller时,指向:
permission denied
。 For what I found, this is because its a directory I trying to compile, but when I compiled the __main__.py
it compiled normally, but when I try to execute it says: Error! No eplusplus module founded!
对于我发现的情况,这是因为它是我尝试编译的目录,但是当我编译
__main__.py
它通常已编译,但是当我尝试执行时,它说: Error! No eplusplus module founded!
Error! No eplusplus module founded!
I have no setup.py file and I don't know how they worked. 我没有setup.py文件,也不知道它们是如何工作的。
After some very intensive research and error and try I succeeded by doing this: 经过一些非常深入的研究和错误,然后尝试通过以下方式成功完成了工作:
I added an empty __init__.py
at the eplusplus
folder 我在
eplusplus
文件夹中添加了一个空的__init__.py
Out of the eplusplus
folder, I had to write a compilation.py
file (the file doesn't necessary must have this) to include all libraries I was using (I will post the file at the end of this answer) 在
eplusplus
文件夹之外,我必须编写一个compilation.py
文件(该文件不一定必须具有此文件)以包括我正在使用的所有库(我将在此答案的结尾发布该文件)
Finally, at the PowerShell, all I have to type was py compilation.py py2exe
最后,在PowerShell上,我只需要输入
py compilation.py py2exe
Thanks for all that tried to help me! 感谢您为我提供的所有帮助!
compilation.py
file: compilation.py
文件:
#To compile we need to run: python compilation.py py2exe
from distutils.core import setup
from glob import glob
import os
import py2exe
import pyDOE
VERSION=1.0
includes = [
"sip",
"PyQt5",
"PyQt5.QtCore",
"PyQt5.QtGui",
"PyQt5.QtWidgets",
"scipy.linalg.cython_blas",
"scipy.linalg.cython_lapack",
"pyDOE"
]
platforms = ["C:\\Python34\\Lib\\site-packages\\PyQt5\\plugins" +
"\\platforms\\qwindows.dll"]
dll = ["C:\\windows\\syswow64\\MSVCP100.dll",
"C:\\windows\\syswow64\\MSVCR100.dll"]
media = ["C:\\Users\\GUSTAVO\\EPlusPlus\\media\\title.png",
"C:\\Users\\GUSTAVO\\EPlusPlus\\media\\icon.png"]
documents = ["C:\\Users\\GUSTAVO\\EPlusPlus\\docs\\"+
"documentacaoEPlusPlus.pdf"]
examples = ["C:\\Users\\GUSTAVO\\EPlusPlus\\files\\"+
"\\examples\\baseline2A.idf",
"C:\\Users\\GUSTAVO\\EPlusPlus\\files\\"+
"\\examples\\vectors.csv",
"C:\\Users\\GUSTAVO\\EPlusPlus\\files\\"+
"\\examples\\BRA_SC_Florianopolis.838970_INMET.epw"]
datafiles = [("platforms", platforms),
("", dll),
("media", media),
("docs", documents),
("Examples", examples)]
imageformats = glob("C:\\Python34\\Lib\\site-packages\\PyQt5\\"+
"plugins\\imageformats\\*")
datafiles.append(("imageformats", imageformats))
setup(
name="eplusplus",
version=VERSION,
packages=["eplusplus"],
url="",
license="",
windows=[{"script": "eplusplus/__main__.py"}],
scripts=[],
data_files = datafiles,
options={
"py2exe": {
"includes": includes,
}
}
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.