Search code examples
pythontelegramtelegram-botdotenv

'dotenv' module not found in a python3.7 Telegram Bot hosted in PythonAnywhere


I am trying to install my TelegramBot based on Aiogram on PythonAnywhere servers. I setup the environment based on python3.7 I installed my dependencies with:

pip install -r requirements.txt --user

I set up the environment and launched it with:

virtualenv env
. env/bin/activate

But once I launch my app this is the result with an error apparently on load_dotenv:

(env) 22:35 ~ $ python3 main.py
Traceback (most recent call last):
  File "main.py", line 4, in <module>
    import dispatcher
  File "lib/dispatcher.py", line 2, in <module>
    from dotenv import load_dotenv
ModuleNotFoundError: No module named 'dotenv'

Any ideas why on PythonAnywhere server the python-dotenv library seems not working properly?

Thanks


Solution

  • This was the correct path to follow:

    virtualenv -p python3 env
    
    . env/bin/activate
    
    pip3 install -r requirements.txt
    
    

    Otherwise there was a confusion also in the python versions.