First thing's first: my OS is openSUSE Tumbleweed, my Python version is 3.11.7, and my pip version is 23.2.2
My goal is as follows: I want to use pip to install the pytictoc package into a virtual environment I create with Python.
My understanding of how to do this is:
- Run
python3 -m venv env
to create a directory calledenv
for my virtual environment. - Then, within that directory, I run
source bin/activate
to activate the virtual environment - Ensure that the virtual environment is indeed running;
(env)
should appear at the start of the current line, and any subsequent lines. - Run
python -m pip install pytictoc
to install the pytictoc package to the virtual environment
When trying to execute these steps, 1-3 go without any problems, however running the command in step 4 yields the externally-managed-environment
error. Here is the full error message:
error: externally-managed-environment
× This environment is externally managed
╰─> To install Python packages system-wide, try
zypper install python311-xyz, where xyz is the package
you are trying to install.
If you wish to install a non-rpm packaged Python package,
create a virtual environment using python3.11 -m venv path/to/venv.
Then use path/to/venv/bin/python and path/to/venv/bin/pip.
If you wish to install a non-rpm packaged Python application,
it may be easiest to use `pipx install xyz`, which will manage a
virtual environment for you. Install pipx via `zypper install python311-pipx` .
As far as I can tell, I'm doing everything right, so I'm lost as to how to approach this. I've seen solutions involving tacking on --break-system-packages
to pip, but this seems to be for cases where the user is NOT using a virtual environment. As far as I can tell, there are no other forums where someone has my exact problem, except this askubuntu question. The user responded to the top answer, explaining that they still receive the error message despite being in a virtual environment. However, this comment didn't receive any response.
There may be other solutions, such as using pipx, or other virtual environments like conda. Unfortunately, for me it is essential that I make the virtual environment with venv, and that I use pip to install the package "pytictoc" specifically. I cannot install the package system-wide.
I appreciate any help or response anyone is able to offer. Thank you for taking the time to read this!
type -a python
— is it the Python from theenv/bin
? – Photolysispython is aliased to `/usr/bin/python3.11' python is /~/env/bin/python python is /usr/bin/python python is /bin/python
I should have mentioned that I have python3 aliased to python on my computer – Twopiece