Running pip freeze
in the terminal throws the following error (full traceback):
PS C:\Users\lhott> pip freeze
ERROR: Exception:
Traceback (most recent call last):
File "C:\Users\lhott\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\cli\base_command.py", line 167, in exc_logging_wrapper
status = run_func(*args)
File "C:\Users\lhott\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\commands\freeze.py", line 87, in run
for line in freeze(
File "C:\Users\lhott\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\operations\freeze.py", line 43, in freeze
req = FrozenRequirement.from_dist(dist)
File "C:\Users\lhott\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\operations\freeze.py", line 237, in from_dist
req, comments = _get_editable_info(dist)
File "C:\Users\lhott\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\operations\freeze.py", line 164, in _get_editable_info
vcs_backend = vcs.get_backend_for_dir(location)
File "C:\Users\lhott\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\vcs\versioncontrol.py", line 238, in get_backend_for_dir
repo_path = vcs_backend.get_repository_root(location)
File "C:\Users\lhott\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\vcs\git.py", line 501, in get_repository_root
r = cls.run_command(
File "C:\Users\lhott\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\vcs\versioncontrol.py", line 650, in run_command
return call_subprocess(
File "C:\Users\lhott\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\utils\subprocess.py", line 141, in call_subprocess
proc = subprocess.Popen(
File "C:\Users\lhott\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 966, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Users\lhott\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 1435, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
NotADirectoryError: [WinError 267] The directory name is invalid
I have Python 3.10.2. pip freeze
worked perfectly fine until today and I don't understand why. I have updated it recently but I don't know why that would've caused that. I also can install packages without a problem with pip install
. Example:
Solutions tried:
I actualy found the answer. @Greg7000 saying Maybe one of your dependency is badly installed
actually gave me a hint.
I had a dependency installed (package of a friend) that I uninstalled manually by pressing delete on the corresponding folder instead of doing pip uninstall
. This is likely to have created the error "directory name is invalid". Using pip uninstall
even after deleting the corresponding folder manually worked and fixed the problem.