Problem With Running Python on My self-system-made Virtual Environment

I created a virtual env on my own system, then I upload it on pythonanywhere. Now I can use source command and activate it, but when I use python command in activated mode, the python of the pythonanywhere's server runs instead of my venv's python. How can I solve it?

(.vi) 20:52 ~/project $ which python                                                                                                                
(.vi) 20:52 ~/project $ python                                                                                                                      
Python 2.7.12 (default, Dec  4 2017, 14:50:18)                                                                                                      
[GCC 5.4.0 20160609] on linux2                                                                                                                      
Type "help", "copyright", "credits" or "license" for more information.                                                                              
>>> exit()                                                                                                                                          
(.vi) 20:52 ~/project $

I expected when I run which python command, It shows ~/project/.vi/..../python3.7. I had installed python3.7 on my virtual env and when I run python command I see the console of python2 on bash.

Is there any other ways to carry my installed libraries with my script? Is it a good way to use the virtual envs?


Uploading a virtualenv is generally not a good idea -- they have internal state that is connected to the computer where they were first created, and can break in weird ways.

The best way to have a virtualenv on PythonAnywhere that mirrors one that you have locally is to run pip freeze in the local one -- this will dump out a list of all of the packages that you have installed into it. Then you can create a file on PythonAnywhere that contains that output (traditionally called requirements.txt) and then create a fresh environment to install those requirements into:

mkvirtualenv mynewenv --python=python3.7
pip install -r requirements.txt

Is there any other way to package my libs and carry them with my script?

Use pip freeze to create a list of the packages your app needs in a file and then create a virtualenv and use pip to install them.