我有一个这样的项目:
├── CHANGES.txt
├── LICENSE
├── MANIFEST.in
...
├── docs
│ └── index.rst
├── negar
│ ├── Negar.py
│ ├── Virastar.py
│ ├── Virastar.pyc
│ ├── __init__.py
│ ├── data
│ │ ├── __init__.py
│ │ └── untouchable.dat
│ ├── gui.py
│ ├── gui.pyc
│ ├── i18n
│ │ ├── fa_IR.qm
│ │ └── fa_IR.ts
│ └── negar.pro
├── setup.py
...
里面是我的文件Virastar.py
需要一些数据data.untouchable.dat
。它工作正常,直到我用这个安装项目setup.py
:
setup(
...
include_package_data=True,
packages = find_packages() + ['negar'],
package_dir={'negar': 'negar'},
package_data={'negar': ['data/*.dat']},
entry_points={
'console_scripts': [
'negar = negar.Negar:main',
],
},
...
)
之后,当我启动程序并且需要该数据文件时,它会返回以下错误:
IOError: [Errno 2] No such file or directory: 'data/untochable.dat'
即使在我的egg-info
来源我找不到任何数据文件:
...
negar/Negar.py
negar/Virastar.py
negar/__init__.py
negar/gui.py
negar/data/__init__.py
我在这里错过了什么吗?
谢谢你们。
编辑:我是否需要添加任何特殊的东西init.py?
我必须补充一点:我使用了 untouchable.dat 就像这样:
f = codecs.open('data/untouchable.dat', encoding="utf-8")