0

I create a Python project using Flask and it works perfectly. Then I upload it to my private Azure repository. After that, another coworker clone the project and try to run in his machine, but it didn't work. He got the following error:

File "run.py", line 1, in <module>
from api import app
File "E:\PUC_Conexao_Colaborativa_API\api\__init__.py", line 7, in <module>
from api.instance.config import app_config, ambiente
ModuleNotFoundError: No module named 'api.instance'

I look on Stackoverflow and found this post: Python error "ImportError: No module named"

One of the answer say that:

  1. You edited init.py on windows.
  2. The windows editor added something non-printing, perhaps a carriage-return (end-of-line in Windows is CR/LF; in unix it is LF only), or perhaps a CTRL-Z (windows end-of-file).

I remember when I install "Git for Windows" exe, it asks for how I want to config the line ending conversions and I select "Checkout Windows-style, commit Unix-style line endings".

Is this the cause that my Python project fails to run in another machines?

The project runs fine on my machine and I copy the entire project and give to the another coworker using a pendrive. When the coworker run the project using the files in the pendrive, it runs perfectly, just like in my machine.

But if I or anyone else try to run the project downloading it from the repository, if fails to run with the error that I mention above.

I suppose the error is caused by the conversion of Git when I push the project to the repo. If am I correct, how can I fix that?

fabiobh
  • 705
  • 2
  • 13
  • 33
  • It's very unlikely that the error has anything to do with line endings. Python is pretty good about understanding line endings. – Mad Physicist Oct 22 '19 at 19:41
  • More likely, the other user doesn't have the right PYTHONPATH or current directory or so. – Mad Physicist Oct 22 '19 at 19:42
  • @Mad Physicist - I think you are right, the problem is probably not the line endings. I copy the project to another repository and config git for windows to not change the line endings, after that I clone the project from the repo and try to run it. It fails too. I don't set a PYTHONPATH in my project. – fabiobh Oct 22 '19 at 20:19

0 Answers0