Locked learning resources

Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Working With Pipenv (Summary)

This course covered the ins-and-outs of pipenv, covering how to:

  • Create virtual environments
  • Install packages
  • Uninstall packages
  • Validate your dependencies

For more information on concepts covered in this course, you can check out:

Download

Sample Code (.zip)

33.0 KB
Download

Course Slides (.pdf)

967.4 KB
Avatar image for Santosh

Santosh on Jan. 18, 2022

Great course as always!

Couple of questions:

  • In the ‘pipenv shell’ environment, when I use Vim/Neovim as my editor, none of the plugins or standard configurations light up. Any thoughts or best practices of ways to enable this as a default?

  • I wrote a simple script that just took a small dictionary and pushed it into a pandas dataframe. Literally, this was my code:import pandas as pd; sample_list = {‘name’:’Moi’,’age’:20}; df=pd.DataFrame(sample_list). I wanted to test this through a Makefile and Github Actions. I had installed ‘pandas’ and the script ran successfully when I ran it in the pipenv environment. However, when I tried to run this through a Makefile as part of Github Actions, it threw this error: “numpy: No module named ‘numpy’” though numpy was part of my dependencies, and my code (as above) did not reference anything numpy-related. I did a “pipenv install numpy” to explicitly add this package. It worked. But it was disappointing since I assumed that numpy was already installed as a dependency. Any thoughts on why that is?…

  • (Makefile contents below)

  • install: pip install pipenv &&\ pip install –upgrade pip &&\ pipenv install –ignore-pipfile
  • run_script: pipenv run python sample.py
  • all: install run_script
Avatar image for Christopher Trudeau

Christopher Trudeau RP Team on Jan. 18, 2022

Hi Santosh,

I’m not going to be much help with you questions unfortunately, but I’ll take a quick stab. Maybe someone else can chime in or you can reach out on the Slack channel?

On my machine, pipenv shell spawns a new bash shell and picks up my environment settings from the parent shell. I use vim myself and can verify that the plugins get picked up.

I’m on macOS. It is possible that a different OS or a different base shell behaves differently. From a quick read of the ‘net, it looks to me like it always spawns a bash shell, but that might not be right. If it is the case – and you aren’t using bash as your base, then your settings won’t get picked up.

As for the dependency problem on GitHub Actions, I don’t know. I can confirm that numpy is listed as a dependency of pandas and if the standard pip install pandas is used, the dependency will get picked up. I’ve never used GitHub Actions, so I don’t know why it would be different.

Sorry I couldn’t be more help.

Avatar image for Santosh

Santosh on Jan. 22, 2022

Thanks Christopher. Appreciate the help and the response. I’ll keep researching… Great courses as always.

Avatar image for Christopher Trudeau

Christopher Trudeau RP Team on Jan. 22, 2022

Hope I was able to at least point you in the right direction. When you figure it out, post it here. Others may have similar questions.

Avatar image for Gattamaneni Kumar Raja

Gattamaneni Kumar Raja on July 21, 2022

Good to run through this tutorial to be aware of this new tool for package management. It was brief and to the point. Thanks for taking your time and building such tutorials Christopher.

Avatar image for Anton

Anton on Sept. 13, 2023

pipenv usage for Python packages mentioned in the end of pre-last video is not clear:

  • is it really needed to maintain the same dependency list in setup.py and Pipenv files ? Looks redundant if so

  • as I know Python projects are recognized by type: applications and packages, and different tools are used for dependency management for those. Does pipenv fit both cases ? pipenv seems to be fully utilized for applications since both virtual env management + dependency management features are used. For package in contrast, dependency management relies on files setup.py\pyproject.toml if I’m not mistaken

Avatar image for Christopher Trudeau

Christopher Trudeau RP Team on Sept. 13, 2023

Hi Anton,

The packaging process in Python is still very much in flux. This course is two years old and the amount of adoption of pyproject.toml has increased greatly in that time.

The intent of the slide you are referring to was to give you a taste of what the tool could do. It is definitely something you’d need to dig into further if you were going to start building packages.

There are other tutorials and courses that touch on packaging:

realpython.com/pypi-publish-python-package/

which give details about pyproject.toml. It doesn’t use Pipenv though.

The Python packaging ecosystem has more tools than it needs, as everyone is unhappy with what is out there and people keep adding new things to the mix. Most of them don’t cover all scenarios, so a lot of it comes down to preference.

Become a Member to join the conversation.