Python Module Not Found Issues after moving directory

岁酱吖の 提交于 2019-12-25 09:25:53

问题


I am working on some repacking of a project that has a variety of different technologies involved. I am trying to move a python module into the project structure for storage in git and have all project files located together.

The python code works in its on folder. I have empty __init__ in each folder and there are no problems with from Documents import *

When I move the folder into my larger project, all of these imports fall apart.

Can anyone please help me to understand what is different? the relative locations seem to be all the same, I wouldn't have thought putting the project in another folder should've affected the ability to see the other modules

Thanks

EDIT:


as mentioned in answers, I try accessing it by nbcu_nes_ingest.Package which appears to work on windows in my dev box. When I deploy it to AWS server where things will live, I get the following.

I cannot run my setup.py anymore and It still doesnt see the import


回答1:


When importing python looks from the root of the structure. In the first example the root is "nbcu_nes_ingest", so when it looks for "Documents" it is directly under the root directory. However, in the second example the root is now "slicer" and there is no "Documents" sub dir directly beneath that. So your import would have to now be "from nbcu_nes_ingest.Documents import NCStoryDocument"



来源:https://stackoverflow.com/questions/45066129/python-module-not-found-issues-after-moving-directory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!