skip to Main Content

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

3

Answers


  1. Chosen as BEST ANSWER

    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.


  2. You need to run pip install -r requirements.txt with the environment activated

    Login or Signup to reply.
  3. It looks like you’re mixing two ways of installing packages. pip install with the --user flag installs packages outside the virtualenv. So you should run

    . env/bin/activate
    pip3 install -r requirements.txt
    python3 main.py
    

    If it still doesn’t work, perhaps you don’t have dotenv in your requirements.txt file? Try doing

    pip3 install dotenv
    

    …and see if that helps.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search