I'm running Ubuntu on Windows and trying to install libraries with pip. However, I'm running into this annoying error about an 'externally-managed-environment.' It suggests using '--break-system-packages,' which seems to help, but I'm not sure if this is related to my setup. I've encountered this issue while trying to install playwright, selenium, pytorch, and the Intel AI framework. Although I'm familiar with Linux for server management, I've never faced this problem when running it locally. Any tips would be appreciated!
4 Answers
The 'externally-managed-environment' message can be a bit misleading. It's not specifically an issue with Ubuntu on Windows. It just means your Python environment is managed by something else. Just try adding the suggested flag, '--break-system-packages', if you need to go ahead with the installation. Just keep in mind it might mess with future package management.
Another option could be to use apt for installing the packages when possible. It's more stable for system-level packages and can prevent some issues that arise with pip installations.
I tried replacing pip with apt but got an 'unrecognized option' error with the command I was running. I need pip for specific packages like PyTorch stated in Intel's documentation.
Using '--break-system-packages' does work, but be careful! It can lead to dependency issues if Ubuntu installs different versions of the same library later on. Just keep an eye on things after installing.
Good to know, thanks!
Instead of using pip, I'd recommend trying out pipx for installing your packages. It's designed to create isolated environments for Python applications, which can help avoid these conflicts.
I'm actually using pip3. The reference from Intel uses pip, which is why I'm sticking with it for now.

Much appreciated!