Forums

Using VirtualEnv to only install EXTRA packages not provided by PA?

Hi there,

I'm really a newbie to Python and PA, so I hope this question makes sense... :-) Is there a way to use a VirtualEnv to only install extra packages not provided by PA? I made a small test web app with flask. To add specific functionality, I want to use Dash (plot.ly), but since this package is not provided by PA, I found out that I could use it via a virtualenv (see https://www.pythonanywhere.com/forums/topic/11357/ and https://www.pythonanywhere.com/forums/topic/11625/#id_post_43420). I decided to create a virtualenv as described on the PA help page (in short: Bash console > mkvirtualenv myvirtualenv --python=/usr/bin/python3.6 (same version as used for web app) + added path to VirtualEnv section on Web tab). I didn't modify the WSGI-configuration file. After reloading my site and checking it, I got a 'Something went wrong :-('-message. Error logs says:

 2017-10-11 13:19:33,479: Error running WSGI application
 2017-10-11 13:19:33,508: ModuleNotFoundError: No module named 'flask'

Obviously all necessary packages can't be found. I did install Flask, SQLAlchemy, Flask-SQLAlchemy but than got the message in the errorlog:

 `ModuleNotFoundError: No module named 'mysql'`

I reckoned I could go on forever like this and thought there must be a simpler way, i.e. still be able to use the system packages and only having to install the extra ones I need (e.g. Dash). Is this possible and how to achieve it?

Thanks in advance for the information!

you can use the --system-site-packages option. but it's a better idea to just make sure you have all and only the packages you need in your virtualenv. I'm sure it won't take much longer! how about pip install mysqlclient, as per https://help.pythonanywhere.com/pages/UsingMySQL/

Thanks for the advice! Since I have a free account and thus limited quota, I decided to go for the --system-site-packages option, however instead of reinstalling a new virtualenv, I simply removed the file no-global-site-packages.txt in my Lib folder under my virtual environment (see https://stackoverflow.com/questions/3371136/revert-the-no-site-packages-option-with-virtualenv). And it worked! :-)