Cool article, but I don't agree with using pipenv. From what I understand pipenv is just a wrapper for people who can't use virtualenv. Virtualenv is pretty easy for me to use and straightforward , so I'll stick to that for now.
Here are some links that are related for anyone interested:
- ~~~ embed:d9fab4f609e9f75941946be45000632b - Install virtualenv on Ubuntu gist metadata:R2VveWkvZDlmYWI0ZjYwOWU5Zjc1OTQxOTQ2YmU0NTAwMDYzMmIgLSBJbnN0YWxsIHZpcnR1YWxlbnYgb24gVWJ1bnR1 ~~~
- How to create and activate virtualenv: https://yoirtuts.com/index.php?title=Create_Virtual_Env_And_Activate_Python3
One of my favourite practices is to often cleanup my virtualenv and reinstall dependencies, especially in big projects with many dependencies. This helps me solve dependency issues,but can be a pain in the ass for development.
Create list of installed packages:
virt-env ) $ pip3 freeze > uninstall-requirements.txt
virt-env ) $ pip3 uninstall -r uninstall-requirements.txt -y
virt-env ) $ pip3 install -r requirements.txt
Pipenv is not a wrapper, there is virtualenvwrapper that you are likely thinking of.
Pipenv is a completely different project that works differently from virtualenv but does the same thing just better.
Ok fair enough. I work in Python everyday so I should have probably known that.
What makes it better than virtualenv?
Btw here are some old notes of mine about virtualenv, not sure if it is still relevant, but it was pretty interesting when I learned about this:
https://yoirtuts.com/index.php?title=Virtualenv_Correct_Usage
WIthout getting complex, there are a lot of advantages. I really recommend checking out the project page and within five minutes I will bet you will see the advantages.
It is not just an ease of use wrapper, it's a complete makeover on how virtual environments work on python and puts it in the same league as NodeJS's package manager.
Thanks. I'm actually sitting and working on a Django project right now. Gonna try it right now :)
Let me know what you think!
I tried installing it in a virtualenv and then I saw it installed virtualenv inside the virtualenv, which is like virtualenv inception. I'm going to try it again tomorrow. I think the change of workflow will take some time to adapt for me. I weirdly like uninstalling everything in my virtualenv and then installing from scratch from my requirements.txt, and the reason behind that is I work on some projects that have a huge list of dependencies(far too many for my liking) and often a package gets out of date or can't install anymore or a certain bug only creeps in with a specific version of a package. Are there any tools out there for converting your requirements.txt to the format that pipenv uses?
I haven't used it in a virtualenv environment, but I believe it will read in a .env file. I would recommend removing the virtual env all together, and reinstalling the packages using
pipenv install ...
and it will handle it all.Just make sure you are in the project folder.
pipenv
makes it really easy to uninstall/install modules and will handle adding only modules you need.Why slowly, you can learn it in about 5 minutes, and benefit from it by the 6th. It's really a huge improvement over previous options.
You can find me on our Discord or many others.