Last Updated: 1/8/2025
This should qualify as a PSA: (but I am biased)
I am so happy I could cry. I knew about a problem on my most favorite and central desktop and I just been living with it – for a long, long … long time.. I have gone in some cases to good lengths to avoid options that I knew would make me come back and face this. I could imagine I was in a Looney Tunes cartoon – the one where the character is trying to convince himself of what he is looking for, and successively gets closer. This is the 2nd (or is it the 3rd?) time I have gone back did the usual; remove all unused programs; give a evil and close eye at my AV, removed my VPN software on the odd chance that something was futzing with either the firewall or whatever, I just thought my problem had to be deep.
The problem was usually preceded with the dreaded message: FileNotFoundError: [Errno 2] No such file or directory: (note the rather random location). (No creating the directory it didn’t solve my problem – or I probably would still be living with this)
As an aside: I would get this problem with running python on lots of tasks, even items even where I knew data was local to my machine (like re-installing pip after I did something very, very bad to it)
File "C:\Users\User\AppData\Local\Temp\tmpuqwhy6sf\pip.zip\pip\_vendor\requests\__init__.py", line 159, in <module>
File "C:\Users\User\AppData\Local\Temp\tmpuqwhy6sf\pip.zip\pip\_vendor\requests\api.py", line 11, in <module>
File "C:\Users\User\AppData\Local\Temp\tmpuqwhy6sf\pip.zip\pip\_vendor\requests\sessions.py", line 15, in <module>
File "C:\Users\User\AppData\Local\Temp\tmpuqwhy6sf\pip.zip\pip\_vendor\requests\adapters.py", line 80, in <module>
File "C:\Users\User\AppData\Local\Temp\tmpuqwhy6sf\pip.zip\pip\_vendor\urllib3\util\ssl_.py", line 359, in create_urllib3_context
FileNotFoundError: [Errno 2] No such file or directory: 'cL\\log'
The relevant dumb ssl_.py file looks like
# Enable logging of TLS session keys via defacto standard environment variable
# 'SSLKEYLOGFILE', if the feature is available (Python 3.8+). Skip empty values.
if hasattr(context, "keylog_filename"):
sslkeylogfile = os.environ.get("SSLKEYLOGFILE")
if sslkeylogfile:
context.keylog_filename = sslkeylogfile
return context
It turns out either I or some testing software had set an environment variable SSLKEYLOGFILE I have no idea why, but there it was none the less.
The fix, (to save some time…..) Just remove it. 🙂 Do the following.
Click Start
Click Run
Type sysdm.cpl and hit enter
IF you did NOT do this… there is a good chance that the version of the Environment Settings will show; and you will be able to edit for the user – but not the system.
Click advanced; go to the System Variable and just simply delete the offending environment variable.
So much pain for something so small.
Now, we can test.
C:\New>type test.py
import httpx
result = httpx.get("https://httpbin.org/get?hello=world")
print(result)
C:\New>python test.py
<Response [200 OK]>
And we appear to be good to go again!