Pipenv

The new, better way to manage a virtualenv for your python projects

đź“… 09 Mar 2021

This will not be an exhaustive post. Not many of my posts are. But I wanted to shed some light on a nice little development that maybe a few people aren’t aware of.

I worked as a back-end developer during the summer of 2020. I can’t tell you how many types I had to use pip and virtualenv. I honestly was bewildered by the virtual environment when I first started and screwed more than a few things up.

Enter pipenv.

OK, I haven’t used this a ton. Just a few personal projects - none of which had crazy dependancies.

But let me tell you, pipenv is super easy to use. To install, just open a terminal and type the following:


  $ sudo -H pip install -U pipenv

Next, go ahead and make a project folder. Go ahead and do it - I dare you.


  mkdir myproject

Then, install your favorite packages:


  $ cd myproject
  $ pipenv install requests

And this is where the magic happens. Unless you were smart and read ahead, pipenv will now create a virtual environment, create a Pipfile, and create a Pipfile.lock.

You can then put together a simple .py file to test everything. But most importantly, how do you activate the virtualenv? For pipenv, the command is just:


  $ pipenv shell

Note though that deactivating is also different than if you have used pip and virtualenv together. To exit the virtual environment, just type “exit”.

That’s it for now. Cheers.

Day 41: #100DaysToOffload



đź’¬ Looking for comments?

I don't have comments on this site because I don't feel like managing them.

Instead of leaving a comment, feel free to ✉️ contact me instead.