Can't find 'socket'

Can you run it from “IDLE” to compare.

One observation from the traceback:

You are importing names from the package library charset_normalizer into the module api and then importing that module into other modules. Can you instead try removing the middle man (i.e., api), and instead import directly from the charset_normalizer module package into the other modules (wherever you are currently importing the api module into).

For example, comment this line out:

from .api import from_bytes, from_fp, from_path, is_binary # comment this line out

and replace with:

from charset_normalizer import from_bytes, from_fp, from_path, is_binary

Technically should not make a difference, but just to verify.

The discussion has picked up on several things now that would be worth investigating, if they were in Arthur’s code, but unless I’ve misunderstood badly, they are part of requests. I don’t think that’s the place to look.


If import requests leads to that traceback, something is wrong with the environment or the installation of requests. We have seen maybe 4 tracebacks now, and in 3 of them the problem is that Python cannot fnd a DLL we all know ought to be there. It is odd that we didn’t see the same under IDLE.

@abrogard You’re quite right. Never mind requests and charset_normalizer or any code you wrote. If you can’t run Python and load the REPL, then Python is broken on your machine. And it seems to be something to do with loading DLLs.

PyREPL is new in 3.13, but it is supposed to work, even on Windows. The explanation of why it can’t on your machine is significant. Did you get a prompt >>> next, or did it just stop there?

This is not a corner of CPython I know well, but almost certainly we are here:

and that’s because this system call failed:

I know, it’s a bit desperate to resort to the source code. I only do it to show that something is quite fundamentally wrong. It’s not to do with the syntax of an import statement. I think we are left with:

  1. It’s looking in the wrong places.
  2. It is looking in the right places but there is nothing there (or something invalid?).
  3. It is looking in the right places, and the right thing is there, but something prevents it being read.

Let’s find out how bad this installation is, avoiding the REPL. Does this work (at the command prompt where you ran the command python):

PS vsj> python -V
Python 3.13.0

This should tell you where Python looks for things:

PS vsj> python -c"import sys;print(sys.path)"
['', 'C:\\Users\\Jeff\\AppData\\Local\\Programs\\Python\\Python313\\python313.zip', 'C:\\Users\\Jeff\\AppData\\Local\\Programs\\Python\\Python313\\DLLs', 'C:\\Users\\Jeff\\AppData\\Local\\Programs\\Python\\Python313\\Lib', 'C:\\Users\\Jeff\\AppData\\Local\\Programs\\Python\\Python313', 'C:\\Users\\Jeff\\AppData\\Local\\Programs\\Python\\Python313\\Lib\\site-packages']

This is a clean installation on my machine. Anything like yours? There is a directory called DLLs in the list. I see 43 items there, mostly .pyd files and some .dll. You?

If bits are missing, the installation went wrong. (Full disk? Security software?) If they’re there but don’t load e.g when you import _socket, that suggests something is interfering. (Security software?)

There is a path length limitation on Windows, which the installation invites you to disable. That could be a reason for not finding files you know are there.

Finally, you can run

PS vsj> python -m test

which is thorough, but takes a lunch break to run on my machine.