squeaky-pl / japronto

Screaming-fast Python 3.5+ HTTP toolkit integrated with pipelining HTTP server based on uvloop and picohttpparser.
MIT License
8.61k stars 581 forks source link

Error in module import #113

Open alansousa opened 6 years ago

alansousa commented 6 years ago

A hello world app works fine. but when I try to add imports of my modules, I get this ModuleNotFoundError or ImportError exceptions.

from my_module import MyClass or from .my_module import MyClass

Traceback (most recent call last):
  File "/usr/local/bin/japronto", line 7, in <module>
    from japronto.__main__ import main
  File "/usr/local/lib/python3.6/site-packages/japronto/__main__.py", line 29, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/site-packages/japronto/__main__.py", line 26, in main
    run(attribute, args)
  File "/usr/local/lib/python3.6/site-packages/japronto/runner.py", line 77, in run
    runpy.run_path(attribute)
  File "/usr/local/lib/python3.6/runpy.py", line 263, in run_path
    pkg_name=pkg_name, script_name=fname)
  File "/usr/local/lib/python3.6/runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/usr/local/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "app/japronto-app.py", line 9, in <module>
    from requisicao import Requisicao
ModuleNotFoundError: No module named 'requisicao'
tejastank commented 6 years ago

JAPRONTO IS JUST FAST FAST AND FAST, ELSE NO DOCUMENT, NO QUALITY, NO CORE TEAM TO MAINTAIN, NO SUCH ROAD MAP FOR UPGRADE OR FUTURE PLAN.

FOCUS TO THIS, IS BIG FAIL IN PLAN TO USE THIS

sidharta commented 6 years ago

I was having the same problem and I solved it using PYTHONPATH env variable. Just set it to your folder, the folder you want your modules to be loaded. In my case, using docker:

ENV PYTHONPATH /home/service

Hope this helps you!