0

Recently I bought a droplet in digital ocean to put my project live.It works just fine in my local computer and doesn't have any problem with the directory structure.However once I put this on a server, Python throws an error.Below is my project structure in my local computer.

enter image description here

Now when I move it to a server, this is my project structure

enter image description here

Now If I run a test file just to test the imports

cd integretation
ls

__init__.py  __pycache__  request_constructor.py  test.py

test.py

from format_data.output_filter import output_filter


print("Yes")

Now I run the file

python3 test.py

I get an error

Traceback (most recent call last):
  File "test.py", line 1, in <module>
    from format_data.output_filter import output_filter
ImportError: No module named 'format_data'

Why is that happening though the same import structure works in my local computer? I even tried to change the import to something like this

from service_rest.format_data.output_filter import output_filter

But this doesn't help either.What is going wrong?

Note: I have removed the topmost level directory ServiceHandler when transferring the files to the server.But adding it back doesn't help either.

Souvik Ray
  • 2,899
  • 5
  • 38
  • 70
  • down vote When you print(url_for('index')) (assuming you are using some sort of web framework like flask), what is the directory it shown? And what is your server's root directory setting – hcheung Mar 10 '18 at 05:31
  • @well I can't use your command because before it runs, I get all sorts of import errors.I am using flask by the way. – Souvik Ray Mar 10 '18 at 05:39
  • Did you Install all the Python packages on Digital Ocean? – hcheung Mar 10 '18 at 05:49

0 Answers0