I created a virutal env and installed Flask framework. When I run python3 -m pip freeze, on Windows it lists only 9 dependencies, but on Ubuntu, it shows approx 75. So why results are different on 2 platforms and how it can be controlled/corrected.
Thank you in advance
I created a virutal env and installed framework.
What’s framework? Got a URL?
When I run python3 -m pip freeze, on Windows it lists only 9
dependencies, but on Ubuntu, it shows approx 75. So why results are
different on 2 platforms and how it can be controlled/corrected.
Can you show the two outputs?
Ubunut does install fewer packages in the system python unless you ask
for them explicitly using
apt; maybe more are being filled in by pip
on your Ubuntu machine and maybe your Windows Python install has more
stuff out of the box. Where/how did you obtain the Windows Python?
There may be nothing to correct here.
Cameron Simpson firstname.lastname@example.org
Thank you so much Cameron for your inputs and sparing time on it. It was wrong analysis from my end, sorry about it. It should be like this: after installing framework(Flask), on Ubuntu, when ran command: python3 -m pip freeze, it showed same output as Windows. But when ran this command on Ubuntu as: sudo python3 -m pip freeze, it showed >70 dependencies.
pip freeze shows you all the third party Python package installed in the active environment, not just the dependencies of whatever you just installed.
On Windows, you presumably had installed a fresh copy of Python, or a fresh virtual environment (
venv), assuming you ran the same command you show on Linux. By default, this doesn’t have anything installed but a few bootstrap dependencies (which
pip freeze doesn’t generally show), and then installed Flask, so you’re just seeing Flask’s dependencies there. T
On Linux, the same thing happens when you created a
venv, as its a new, fresh Python environment that will only contain what you yourself actually install, which again are the dependencies of Flask.
However, when you ran
sudo python3, it is also showing the Python packages installed by default with your system (or perhaps that you installed another time), not just those in the venv. In general, you should NEVER run
sudo pip anything, as that will modify the packages installed in your system Python which are be required for your operating system and its package manager to work properly, and thus could cause serious problems up to and including requiring a complete clean reinstall of your operating system.
Most modern distros will actually completely prevent you from doing this unless you pass a special
--break-system-packages flag to
pip. Instead, just use a
venv (as you did), so worst comes to worse you can simply delete just the env and reinstall the packages you want instead of completely reinstalling your entire OS.
Thank you so much for providing such insightful info and making me aware on the side effects of using sudo pip