Model.pth crash python in windows environment

I’m running python 3.11 in a virtual environment (venv) pytopch
Latest Windows 11, Home

after execute the quickstart tutorial and generate a model.pth file, I can no longer invoke a simple python command

The .pth file is treated as a path configuration file! thus invalid character map

before:
$ python -m pip -V

pip 24.0 from C:\Users\xxxxx\pytorch\Lib\site-packages\pip (python 3.11)

after:
$ python -m pip -V

Fatal Python error: init_import_site: Failed to import the site module
Python runtime state: initialized
Traceback (most recent call last):
File “”, line 1176, in _find_and_load
File “”, line 1147, in _find_and_load_unlocked
File “”, line 690, in _load_unlocked
File “”, line 980, in exec_module
File “”, line 616, in
File “”, line 599, in main
File “”, line 531, in venv
File “”, line 384, in addsitepackages
File “”, line 226, in addsitedir
File “”, line 179, in addpackage
File “C:\Python311\Lib\encodings\cp1252.py”, line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: ‘charmap’ codec can’t decode byte 0x8d in position 1276: character maps to

The reason is clear if I use python -v -m pip -V


import ‘os’ # <class ‘_frozen_importlib.FrozenImporter’>
import ‘_sitebuiltins’ # <class ‘_frozen_importlib.FrozenImporter’>
Processing global site-packages
Adding directory: ‘C:\Users\xxxxx\pytorch’
Processing .pth file: ‘C:\Users\xxxxx\pytorch\model.pth’
Fatal Python error: init_import_site: Failed to import the site module
Python runtime state: initialized
Traceback (most recent call last):
File “”, line 1176, in _find_and_load
File “”, line 1147, in _find_and_load_unlocked