0

On a Windows 10 machine, I have two versions of Python 3. First, I have 3.7.2 installed with QGIS. There is also a version 2.7 with QGIS, but I haven't used that at all. I was using 3.7 as my default Python when I did a few things in Python and I could call that with python3. Now, I'm using Python more and I need a newer version because of package needs. I got the official 3.9.6 from python.org and it seemed to install fine. (I'm also trying to get used to pipenv, but I haven't quite figured all of the virtual environment thing out yet. Just mentioning that, I don't think that's the real problem for me.)

Whether I use pipenv or call py -3.9 (found this command here) on a command prompt, I get this error message:

C:\Users\jp>py -3.9

Error processing line 1 of C:\OSGeo4W64\apps\Python37\lib\site-packages\matplotlib-3.1.3-py3.7-nspkg.pth:

Traceback (most recent call last): File "C:\OSGeo4W64\apps\Python37\lib\site.py", line 168, in addpackage exec(line) File "", line 1, in File "C:\OSGeo4W64\apps\Python37\lib\importlib_init_.py", line 51, in _w_long = _bootstrap_external._w_long AttributeError: module 'importlib._bootstrap_external' has no attribute '_w_long'

I tried calling python3 on the cmd and that caused a Bing window to open and take me to the Microsoft Store to download Python 3.

I changed the PATH setting on the computer. I thought I had the environment taken care of, but apparently not. Something is eluding me and I don't know what setting I need to change. I did have "C:\OSGeo4W64" on my PATH, but I took that out. I've logged out and back in for the changes to take effect. What else do I need to change so that calling python3 just looks in C:\Program Files\Python39?

John Polo
  • 547
  • 1
  • 8
  • 25

1 Answers1

0

I'm assuming you aren't using C:\program files\python39 for OSGeo4 work. I've had the best luck on Windows 10 installing python from the Microsoft store. That version comes pre-configured with a shortcut to a terminal with all the correct variables set.

It's mainly that OSGeo4W64 is on your PATH either before or instead of your desired python location. I wouldn't advise just adding it to your user's PATH because it may break OSGeo in weird ways (small chance).

Maybe "python launcher" has been installed. You can try that. Otherwise, here's the setup guide. https://docs.python.org/3.9/using/windows.html

  • Thanks for suggesting python launcher. That's the `py -3.9` I alluded to in my question. That still has an error. I took OSGeo4W64 out of my PATH completely (I know QGIS won't work, but I just did that as a test. I'll put it back) and I still get the error that led to this question. – John Polo Aug 09 '21 at 21:48