我有這樣一個項目:添加數據文件到Python項目的setup.py
├── 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(
...
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',
],
},
...
)
當我開始我的程序,當它需要一個數據文件,它返回此錯誤:即使在我egg-info
來源
IOError: [Errno 2] No such file or directory: 'data/untochable.dat'
,直到我安裝這個setup.py
項目,它工作正常我找不到任何數據文件:
...
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")
在Python 2.7,他們改變了文件的方法包括對MANIFEST.in或東西 - 我不知道,也沒有使用它,但它可能是一個方向 – zenpoy
我在Python 2.6!出於某些原因,我現在無法升級! – Shahinism