Note: If you don’t know about virtualenv See here

But so you know, virtualenv is a tool to create isolated Python environments. Since Python 3.3, a subset of it has been integrated into the standard library under the venv module. Note though, that the venv module does not offer all features of this library (e.g. cannot create bootstrap scripts, cannot create virtual environments for other python versions than the host python, not relocatable, etc.).

Okay, so on a faithful Friday, i received a project file i had to unzip and work on. As an expert i feel i am πŸ˜€ , i unzipped, configured virtualenv, open the code and realize it was made in Python 2, while i have python 3 configured πŸ™ , not bad.

Peep the API made using Python 3

I pulled google over, and downloaded Python 2 MSI, Install did all my windows environment variables setting as seen below;

Tip: Did you know that if you move the paths up and down, one on top takes precedence over the one below? I notices this when i tried to run ‘Python’ in the CLI. You can try it, if you have multiple versions of python installed

That was just by the way

virtualenv

Alright, now after setting up Python 2.

while in the project directory. i ran virtualenv env in CLI , it is still using c:\\python36. To fix this and use Python27 for virtual env. Just run

Note: Before this, ensure you delete the old env folder which was generated

virtualenv -p C:\\Python27\\python.exe env
virtualenv

Activate the Environment

source ./env/Script/activate

Install your requirements

pip install -r requirements.txt

Now we good! πŸ™‚


Vinay

Lead software engineer with over 5 years in development and 7+ years in network engineering. Recognised educator, substantial online presence, and MSc. Cybersecurity from the University of Derby, UK, BSc. Information Technology from UEW Ghana, and a Higher Diploma in Network Engineering from NIIT India.

1 Comment

Gnaneshwar Gaddam · May 2, 2020 at 3:35 am

Amazing!

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.