[英]FileNotFoundError after python setup.py install (not after develop!)
I have a python project with the following structure:我有一个具有以下结构的python项目:
src/
main.py
example.txt
setup.py
After installation, I should be able to call myprogramm -name bla
and it should create a new folder bla
and copy example.txt
inside.安装后,我应该能够调用
myprogramm -name bla
并且它应该创建一个新文件夹bla
并在其中复制example.txt
。
When installing the program with python setup.py develop
(inside a virtualenv) everything works fine and as expected.使用
python setup.py develop
(在 virtualenv 中)安装程序时,一切正常且符合预期。 However, when using python setup.py install
, I get a FileNotFoundError
when executing the command as Python cannot find example.txt
.但是,当使用
python setup.py install
,我在执行命令时收到FileNotFoundError
因为 Python 找不到example.txt
。
Why doesn't it copy example.txt
to the correct location when installing with python setup.py install
?为什么在使用
python setup.py install
时不将example.txt
复制到正确的位置? How can I fix the problem?我该如何解决这个问题? Do I need to include
example.txt
explicitly in my setup.py
somehow?我需要以某种方式在
setup.py
明确包含example.txt
吗?
Including a MANIFEST.in
and adding include_package_data=True
in my setup.py
solved my problem.包括一个
MANIFEST.in
并在我的setup.py
添加include_package_data=True
解决了我的问题。
Apparently, package_data
does not behave how you would expect: https://stackoverflow.com/a/14159430/2745116显然,
package_data
行为与您预期的不同: https : //stackoverflow.com/a/14159430/2745116
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.