ModuleNotFoundError: No module named 'pvlib'

I have installed a library, pvlib, into my virtual environment. I can use the library just fine in the console but when I try to use it in my web app I get a module not found error.

I have read the instructions at and confirmed that if I run my file I can import the library without any issue.

My web app is running Flask but the following test code will fail to execute.

from flask import Flask
import pvlib
app = Flask(__name__)
def flasktest():
    return 'Hello, World!'

Is your web app set up to use that virtual environment?

yes, the web app runs fine without the import statement

I may have found the problem, but still not sure how to address it.

If I open a bash console, switch to my virtual env, and run 'python -i /var/www/', followed by 'print('\n'.join(sys.path))' I will see my site-packages directory included:


However, if I simply go to the file directly from the directory listing and open it up there and run the same command, then my site-packages directory is not listed.

Is there a way to make sure this path is always included?

On the "Web" page inside PythonAnywhere, if you scroll down to the "Virtualenv" section, underneath "Code", you'll see an option where you can tell the web-serving system which virtualenv to use. You can just enter "solar" there -- because your env is in the standard location, it will be able to work out the rest of the path.

thank you! that did it! I had assumed that because the 'source code' value was already set to that directory that was all that was needed.

Thanks for letting us know!