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:
- How to Publish an Open-Source Python Package to PyPI
- What Are Python Wheels and Why Should You Care?
- The Real Python Podcast: Episode 83: Ready to Publish Your Python Packages?
- Pipenv: Python Dev Workflow for Humans (documentation)
Congratulations, you made it to the end of the course! What’s your #1 takeaway or favorite thing you learned? How are you going to put your newfound skills to use? Leave a comment in the discussion section and let us know.
00:00
In the previous lesson, I showed you some of the less common pipenv
commands. In this lesson, I’ll summarize the course. This course was all about package installation and virtual environments using pipenv
.
00:12
You have learned how to use pip
to install a package, where Python puts packages by default, how to use pipenv
to create virtual environments and install packages within them, and how pipenv
handles package conflicts.
00:29 Thanks for your attention. I hope this course was useful for you.
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.
Santosh on Jan. 22, 2022
Thanks Christopher. Appreciate the help and the response. I’ll keep researching… Great courses as always.
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.
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.
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
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.
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)