How to use Python version installed with another package as my base Python?

I’m using Windows 10. I have QGIS installed. It comes with Python 3.9. I want to use that as the default Python on my system. Python exists in C:/OSGeo4W64/bin. I was able to use that Python in CMD until yesterday, but then I updated pipenv and now I get an error message (that follows). I uninstalled pipenv and Miniconda. I tried calling “python”, “python3”, and “C:/OSGeo4W64/bin/python.exe” in CMD. Everything I try returns this error message:

Python path configuration:
PYTHONHOME = (not set)
PYTHONPATH = (not set)
program name = ‘python’
isolated = 0
environment = 1
user site = 1
import site = 1
sys._base_executable = ‘C:\OSGeo4W64\bin\python.exe’
sys.base_prefix = ‘’
sys.base_exec_prefix = ‘’
sys.platlibdir = ‘lib’
sys.executable = ‘C:\OSGeo4W64\bin\python.exe’
sys.prefix = ‘’
sys.exec_prefix = ‘’
sys.path = [
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named ‘encodings’

Current thread 0x00002660 (most recent call first):

I tried setting PYTHONHOME and PYTHONPATH to C:/OSGeo4W64/bin and unsetting it. Nothing is working. I can’t get Python to work at all. I started QGIS and ran the Python window built in and it works there. I had a separate Python installed a year ago, but it made problems for QGIS, that’s why I’m trying to use the Python in QGIS, so that I don’t install another Python package and have conflicts.

I think I have solved this problem by calling the python EXE that is in C:\OSGeo4W64\apps\Python39. I don’t know why the python in C:\OSGeo4W64\bin doesn’t work while the the python in C:\OSGeo4W64\apps\Python39 works. Since that seems to work, I added
to my path in environment variables.

Now, I’m trying to find what file or setting creates the “Python path configuration”. That configuration does not reflect the new change in the path and it still includes paths that I’ve deleted, like “‘C:\Users\japolo\Miniconda3\DLLs’,” and I want to edit or reset this configuration, but I can’t tell where it’s saved or how it’s created.