English 中文(简体)
似乎没有发现数据档案
原标题:pyinstaller seems not to find a data file

Edit 3: I replaced __file__ with sys.argv[0], when I need to know the location of my script/executable. This is not exactly the same, but in my case it seems to run fine (at least on executable version...). Now everything is working fine, in one-file mode, with use of accepted answer s function to access resource files!


第2版:如已接受的回答评论所示,问题来自我的发言稿中途经的解决;我试图使用<条码>__>file,以找到文字的位置,以便我能够查阅其资源档案。 如file_,将档案名称从Python.dll退回到文字上,这并非一包工作,因此始终没有一条路,只是一个档案。 因此,我不得不找到另一个渠道来查阅资源档案;目前的工作方向是把目前的目录移至可执行的道路上。

因此,这意味着没收商在查阅档案时应当报告问题,而不是没有一节。

我以我解决这一解决途径问题的方式更新了这一问题。


我在<代码>pyinstaller<>/code>上提出了问题,而且由于这是第一次使用该编号,我确信我做了一些错误的事情。

因此,这里的问题是:pyisntaller。 顺利操作的是文字一,在<条码>dist 上产生一些缺陷。 奥基,我现在想执行这一决议,看看看是否所有方面都做得很好,这里我知道:

C:Program FilesPyInstallerpyinstaller-1.5.1>p_tooldistp_toolp_tool.exe -?
Traceback (most recent call last):
  File "<string>", line 104, in <module>
  File "p_tooluildpyi.win32p_tooloutPYZ1.pyz/logging.config", line 76, in f
ileConfig
  File "p_tooluildpyi.win32p_tooloutPYZ1.pyz/logging.config", line 112, in
_create_formatters
  File "p_tooluildpyi.win32p_tooloutPYZ1.pyz/ConfigParser", line 532, in ge
t
ConfigParser.NoSectionError: No section:  formatters 

My first idea was that the logging.conf file was missing, so I added it (and some other resource files) in the p_tool.spec file, but this is not better.

Python version: 2.6.6, under WinXP. I m using pyinstaller as I will need it to package files for a Solaris workstation.

因此,谁有这一问题? 唯一相关的议题是:。 PyInstaller Problem,与我的问题完全接近,但不幸的是,它没有答案。


Edit3:关于砍伐的详细信息,因为与这一问题没有真正联系。

最佳回答

首先,在阅读文件之前,或许应该做一个印刷版——文件/文件。

关于实际使用该软件的问题,os.path.split(__file__)看差不多正确,但I m不能确定该仪器在Pyinstaller进行适当操作——包装档案的适当方式是将这些档案添加到光谱档案中,因此,Pyinstaller将及时装货,并在操作时将其包装到ESSS2/美元。 为了在包装式样式样式中获取ESIPASS2 dir,并以无包装(发展)方式使用当地名录,我使用:

def resource_path(relative):
    return os.path.join(
        os.environ.get(
            "_MEIPASS2",
            os.path.abspath(".")
        ),
        relative
    )


# in development
>>> resource_path("logging.conf")
"/home/shish/src/my_app/logging.conf"

# in deployment
>>> resource_path("logging.conf")
"/tmp/_MEI34121/logging.conf"
问题回答

错误信息ConfigParser.No节 错误: 无一节:格式表示它不是缺失的档案,而是一份有缺失部分的档案,你应当寻找。

我也存在类似的问题,但迄今看不出任人。 我使用的黑板一指ugh强,即我的项目位于 ~/project/project_root ,先在>。 光谱档案:

excluded_sources = TOC([x for x in a.pure if not x[0].startswith( project_root )])

Here a is the Analysis object, basically I remove all of my projects files from the PYZ so no import is passed there and the logger s relative paths won t be computed from there. After this, create a Tree object from the project.

my_project_tree = Tree( ~/project )

之后,将这 Tree树添加到被传入殖民地的托克清单中:

COLLECT( exe,
           a.binaries,
           a.zipfiles,
           a.datas,
           my_project_tree,
           ....)

你应当把项目倍增到左侧。 问题在于,你最终也散发了你的项目,但迄今还找不到更好的途径。 对有效解决办法非常感兴趣。





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...