Hi, I’ve had long running issues dealing with the environment of Python (especially with multiple installs and virtual environments), but up until now I’ve always been able to find workarounds. However, it’s reached a tipping point where all of my installs are unusable in some way. I have asked in a couple other places, but I must have communicated poorly or caved to frustration, and so I wasn’t able to take away much from those. I thought that perhaps by asking here and exercising lots of self-control, I might be able to get a more proper insight about the situation from people who may be more dedicated.
I’m about to describe the situation in as good of detail as I can, however do note that it is a lot and as such it is likely I will inadvertently leave out important information. Please do ask me for this information if you notice, I will follow up with the information or another question asking for clarification.
First, let’s get the basics out of the way: I’m running Win10 on a PC with a couple of accounts (at setup of the OS I inadvertently created one account without realising, which may be causing some permission issues since the account I use is not that one (but it is an administrator)). I currently have Python versions 3.9.5 and 3.12.6 “installed”, but the installs have become tangled to the point where I can’t figure out what is going on.
The thing that pushed the issues over the edge was when I installed NodeJS a few weeks ago and selected to install the build tools, which included Chocolatey. The Chocolatey install (taking place within powershell) scanned for any installed versions of Python, and says it didn’t find any, which is the first sign of trouble. I had numerous working installs at the time (in C:/…
…/appdata/programs/python), so I don’t know what it’s going on about. Anyway, the install failed with “generic MSI error”, which helpfully explains to me that the environment is messed up (it was messed up quite badly before this point but at least things still worked), and that a probable cause is that Python is already installed (which is correct, but it’s hilarious because it claimed it was not installed). It then provided instructions to try and run the installer again and look at some log files (except the file path it points to does not exist), so I couldn’t progress on that front.
However, the effects of this failed install seem to have been severe. It installed half of a Python installation to C:\Python312, and the (previously working) 3.12.6 install was suddenly missing half of its critical files, including the Python exe itself.
I tried to repair the install, but it doesn’t repair anything, it still leaves behind two unusable Python installs (in case you were wondering, that’s how I ended up here. I decided to give the link in the installer a try after the “repair” option did nothing a few times).
So as a result, everything is on fire, including all the PyCharm virtual environments I had set up, and it has progressed so far that PyCharm seems to be making up installs out of thin air (it has some imaginary 3.11 and 3.13 and 3.10 interpreters in the venv settings), and one exe file is labelled as being somehow both 3.9, 3.10, and 3.12 at the same time in the venv options.
So it is clear to me that the most practical way forward is to somehow reset the Python installs on my system, although I am sure that this will break all the projects I’ve worked so hard on, as the places they expect files to be will be wrong once the reset happens. Additionally, the best reset options I’ve seen seem to be along the lines of “reinstall windows”, which is absolutely not an acceptable option for me.
Perhaps there is a way to perform some kind of “digital surgery” and find out where applications are looking for files, and where environment variables are pointing, and marry everything up; as well as cleaning the references to nonexistent installs and other such things that could cause problems in the future. It could also be possible that there is another way, but I am sure that people here would be the ones to know.
I’ve realised now that I haven’t actually mentioned the exact errors encountered, and I’ll try to do so here:
Upon running the install located in C:\python312:
it works, except with this warning:
Could not find platform independent libraries
As implied by this warning, libraries don’t work. I can’t run pip or import anything for that matter.
Upon trying to setup a new virtualenv in PyCharm:
“the SDK seems invalid” (among many other things, I recognise this may technically not be the best place for PyCharm but it would be a lifesaver if I finally got to the bottom of the nuance with virtual environments so that I don’t break everything every time I create one).
Upon running the previously working 3.12.6 install:
“No Python at C:.…” (expected, the exe is missing from that directory, along with loads of other things, and unfortunately I can’t list all those things since I don’t know every single file off the top of my head).
Another thing to note is that I’ve ran many machines with Python over the last few years, and this sort of problem always pops up every time something wants to install a version of python, or I try to upgrade or move projects or files between PCs, etc. etc. It always leads to a very bad system environment configuration, and the errors and quirks are never ending.
I’m willing to learn a lot and read docs or take courses to build intuition on the topics that are relevant to these issues, because I’d love to be able to one day resolve these issues myself, or better yet, have a proper intuition so that they don’t happen in the first place.
If you made it this far, I sincerely thank you, whether you can help or not. I’m giving it my all this time, and as I’m sure you can imagine, it takes a lot of effort to not cave into the frustration and take shortcuts with the description of the problem, or go on a rant.
I’m anticipating the resolution and troubleshooting process will be very long, but I am committed to getting to the bottom of this, so I will assist with any additional information that may help you guys to help me. Again, thank you so much for reading, and if you can help in any way, that would be much appreciated.