PythonAnywhere –如何使用安装的模块?

问题描述 投票:0回答:1

我对应该在PythonAnywhere中安装/使用新模块的方式感到困惑。

例如,我在Bash控制台中安装了ephem模块

pip3.6 install --user ephem

一切都顺利。如果我再次运行以上命令,它会说;

Looking in links: /usr/share/pip-wheels 
Requirement already satisfied: ephem in ./.local/lib/python3.6/site-packages (3.7.7.0)

但是,当我尝试在脚本中使用它时,会得到:

Traceback (most recent call last): File "/home/krollibrius/montaulieu.py", line 7, in <module> import ephem ModuleNotFoundError: No module named 'ephem'

有人可以帮忙吗?

pythonanywhere
1个回答
0
投票

也许您使用了错误的python版本,请尝试添加

import sys
print(sys.version)

根据您的脚本。我发现大多数时候我都将软件包安装到错误的版本。另一种解决方案是使用命令pythonwithversionnumber -m pip install --user ephem。将pythonwithversionnumber替换为用于运行脚本的命令

© www.soinside.com 2019 - 2024. All rights reserved.