y-young / nazurin

🎉 Images collection done right. Telegram 图片收藏机器人 / A Telegram bot that helps you collect ACG illustrations.
http://nazurin.readthedocs.io
MIT License
263 stars 59 forks source link

Fix module-not-found if deploying on the server #26

Closed SukiEva closed 3 years ago

SukiEva commented 3 years ago

When I try to use python -m nazurin to run the bot, the 'nazurin not found' error pops up.

Fix it by Using module's own objects in main.py

y-young commented 3 years ago

Thanks. But I've never encountered this error, can you provide more details, like your Python version and the error log?

SukiEva commented 3 years ago

Thanks. But I've never encountered this error, can you provide more details, like your Python version and the error log?

In order to facilitate the deployment, I used the python project manager of the BT panel, which seems to be unable to recognize the folder startup correctly.

Log below

ModuleNotFoundError: No module named 'nazurin'
Traceback (most recent call last):
  File "/root/.pyenv/versions/3.7.8/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/root/.pyenv/versions/3.7.8/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/www/wwwroot/nazurin/nazurin/__main__.py", line 9, in <module>
    from nazurin import config, dp
ModuleNotFoundError: No module named 'nazurin'

I searched, and it seems that 'python -m' is ok, and when I use it on the command line, it works well...

So, this seems to be a problem of the manager. However, adding the above can make it easier to start the project through the folder.