[英]'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.我正在尝试在PythonAnywhere服务器上安装基于Aiogram 的TelegramBot 。 I setup the environment based on python3.7 I installed my dependencies with:
我设置了基于python3.7的环境我安装了我的依赖项:
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 :但是一旦我启动了我的应用程序,结果就是在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?任何想法为什么在 PythonAnywhere 服务器上python-dotenv库似乎无法正常工作?
Thanks谢谢
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.否则,python 版本中也存在混淆。
您需要在激活环境的情况下运行pip install -r requirements.txt
It looks like you're mixing two ways of installing packages.看起来您正在混合两种安装软件包的方式。
pip install
with the --user
flag installs packages outside the virtualenv.带有
--user
标志的pip install
在 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?如果它仍然不起作用,也许您的
requirements.txt
文件中没有dotenv
? Try doing尝试做
pip3 install dotenv
...and see if that helps. ...看看是否有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.