我在python中的項目在許多文件中有許多腳本。一般結構是 :在python中創建多平臺安裝程序
Project/
|-- bin/
|-- project
|--calculations
|--some scripts
|--mainApp
|--some scripts
|--interpolations
|--some scripts
|--more files
|--other scripts
|
|-- tests
|-- setup.py
|-- README
我有很多進口這樣
import bin.project.mainApp.MainAppFrame
我的setup.py文件
from setuptools import setup, find_packages
setup(
name = 'Application to orifices',
version = '1.0',
author = "Michał Walkowiak",
author_email = "[email protected]",
description = "Application in python 3.4 with noSQL BerkleyDB",
packages = find_packages(),
entry_points={
'console_scripts': [
'PracaInzynierska = bin.project.mainApp.MainApp:__init__'
]
},
scripts = [
'bin/project/mainApp/__init__.py',
'bin/project/mainApp/MainApp.py',
'bin/project/mainApp/MainAppFrame.py',
'bin/project/informations/__init__.py',
'bin/project/informations/DisplayInformations.py',
'bin/project/informations/InformationsFrame.py',
'bin/project/calculations/Calculate.py',
'bin/project/calculations/UnitConversion.py',
'bin/project/databaseHandler/__init__.py',
'bin/project/databaseHandler/databaseHandler.py',
'bin/project/databaseMonitoring/__init__.py',
'bin/project/databaseMonitoring/DatabaseFrame.py',
'bin/project/databaseMonitoring/DisplayDatabase.py',
'bin/project/initializeGUI/__init__.py',
'bin/project/initializeGUI/CalculationsFrame.py',
'bin/project/initializeGUI/initGui.py',
'bin/project/interpolation/__init__.py',
'bin/project/interpolation/Interpolate.py',
'bin/project/orificeMethods/__init__.py',
'bin/project/orificeMethods/methodsToCountOrifice.py',
'bin/project/steamMethods/__init__.py',
'bin/project/steamMethods/methodToCountParamsSteam.py',
'bin/project/waterMethods/__init__.py',
'bin/project/waterMethods/methodsToCountParamsWater.py'
]
)
我使用setup.py與
python3 setup.py bdist --formats=gztar
它生成dist文件夾與tar.gz文件,但是當我解壓它時,每個腳本都在/ bin文件夾中。當我嘗試通過
python3 MainApp.py
運行MainApp.py我收到一個錯誤:
Traceback (most recent call last):
File "MainApp.py", line 7, in <module>
import bin.project.mainApp.MainAppFrame
ImportError: No module named 'bin'
當我改變
import bin.project.mainApp.MainAppFrame
到
import MainAppFrame
它的工作原理,但它不在Pycharm那裏有通往每個地方的路徑文件。 是否有任何選項可以生成istaller,解包後的路徑與原始項目的路徑相同,還是始終將所有文件添加到一個文件夾?
嗯,不好意思,但對我來說有點過於寬泛。我在linux上工作,正如你可以看到的問題,我已經試圖做你喜歡說的話,問題是保留腳本路徑:'python3 setup.py bdist --formats = gztar'。 P.S我使用QtDesigner來構建GUI – Michu93