【问题标题】:PythonAnywhere – How do I use the modules I install?PythonAnywhere – 如何使用我安装的模块?
【发布时间】:2019-10-02 22:09:07
【问题描述】:

我对如何在 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】:

    可能你用错了python版本,试试添加

    import sys
    print(sys.version)
    

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

    【讨论】:

    • 太棒了,谢谢。只需在 Bash 控制台中使用 python3.6 script.py 运行我的脚本即可解决问题。
    猜你喜欢
    • 2021-07-03
    • 1970-01-01
    • 2012-07-12
    • 2012-07-13
    • 2018-06-15
    • 2015-05-26
    • 2020-02-24
    • 2011-05-20
    • 2016-06-15
    相关资源
    最近更新 更多