Search code examples
pythonanywhere

PythonAnywhere – How do I use the modules I install?


I'm confused by how I'm supposed to install/use new modules in PythonAnywhere.

For instance, I installed the module ephem in Bash console with

pip3.6 install --user ephem

Everything went alright. If I run the above command again it says;

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

However, when I try to use it in my script I get:

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

Can someone help?


Solution

  • Perhaps you used the wrong python version, try adding

    import sys
    print(sys.version)
    

    to your script. I find that most of the time I install packages to the wrong version. Another solution could be to use the command pythonwithversionnumber -m pip install --user ephem. Replace pythonwithversionnumber with the command you used to run your script