0

I've deinstalled and reinstalled a bunch of Python Versions and edited my system variables in order to clean up the quagmire of pip not being able to install packages to the right locations. Long story short: Sublime now can't find numpy (or any 3rd party module), because it somehow figured that the python 2.3 version that comes with ChemDraw is the one I really want to use, not the 3.9 version I had used previously.

I've tried a bunch of tutorials online (such as resetting everything to factory settings) however nothing seems to unlink the python build system from that python 2.3 version that came with ChemDraw. Even deinstalling everything and installing Sublime 4 keeps that association. Like...how?

So here's my problem: My build system for python is linked to the wrong python version and I don't know how to link it to the python 3.9 that's located in AppData/Programs.

How can I associate the python.exe of python 3.9 in AppData with my python Build System instead of the current python 2.3, which is located ProgramFiles?

J.Doe
  • 224
  • 1
  • 4
  • 19
  • Does this answer your question? [Set up Python 3 build system with Sublime Text 3](https://stackoverflow.com/questions/23730866/set-up-python-3-build-system-with-sublime-text-3) – JAV Jun 17 '21 at 16:12
  • Either I'm doing it wrong or it's doing nothing. That's one of the ones I tried. – J.Doe Jun 17 '21 at 16:16
  • Are you selecting the new build system you created in Sublime when you try to run your script? Sublime -> Tools -> Build System... -> – JAV Jun 17 '21 at 16:20
  • Yes I am. I'm choosing python instead of Python and printing out the python path using os.environ(). It's the wrong path for both default (Python) and custom (python) build system. This is the code I saved as python.sublime-build: { "cmd": ["C:/Users/Chris/AppData/Local/Programs/Python/Python39/python.exe", "-u", "$file"], "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)", "selector": "source.python" } – J.Doe Jun 17 '21 at 16:25
  • Also: Is the only option a new build system? Why can't I edit the default path? If Sublime chooses the wrong python install I'll just have to deal with that? – J.Doe Jun 17 '21 at 16:27
  • Have you checked your user and system PATH variables to ensure that `"C:/Users/Chris/AppData/Local/Programs/Python/Python39"` comes before ChemDraw or anything else? That's what the root of the problem is. Also, when changing the PATH, it helps to reboot afterwards so programs aren't using cached copies. – MattDMo Jun 17 '21 at 17:04
  • I didn't know that the order in which paths show up in system path plays a role. Thanks, I'll try that. And yes, I did restart after resetting. Also, should I add my python3.9 path to my system path variable? Because currently it is just a user variable. The python3.9 path is at the top of my user path variable while the chemdraw python path is at the top of the system path variable. I guess system takes precedent over user? – J.Doe Jun 17 '21 at 18:01
  • Nope, still using the wrong one even though it's at the bottom of the list and I reset Sublime and restarted my system. – J.Doe Jun 17 '21 at 18:15
  • I managed to find out what the problem was: There was an additional system var that was called PYTHONPATH. I deleted that and now no python.exe can be found. Do I just make a new PYTHONPATH? Will that find the 3rd party modules? – J.Doe Jun 18 '21 at 00:47

1 Answers1

0

Ok, so the problem was that there was a system variable called PYTHONPATH, which I don't remember setting. It seems that Chemdraw, if installed with ChemScript, installs it's own python installation, which is 2.X.

That python install seems to set its own system variable called PYTHONPATH, which Sublime seems to prioritize for it's default python build system.

Delete whatever incorrect path is set in PYTHONPATH and paste the following into it instead: C:...\Python\Python39\Scripts;C:...\Python\Python39;C:...\Python\Launcher;

J.Doe
  • 224
  • 1
  • 4
  • 19