pip freeze throws "The directory name is invalid"
Question:
Running pip freeze
in the terminal throws the following error (full traceback):
PS C:Userslhott> pip freeze
ERROR: Exception:
Traceback (most recent call last):
File "C:UserslhottAppDataLocalProgramsPythonPython310libsite-packagespip_internalclibase_command.py", line 167, in exc_logging_wrapper
status = run_func(*args)
File "C:UserslhottAppDataLocalProgramsPythonPython310libsite-packagespip_internalcommandsfreeze.py", line 87, in run
for line in freeze(
File "C:UserslhottAppDataLocalProgramsPythonPython310libsite-packagespip_internaloperationsfreeze.py", line 43, in freeze
req = FrozenRequirement.from_dist(dist)
File "C:UserslhottAppDataLocalProgramsPythonPython310libsite-packagespip_internaloperationsfreeze.py", line 237, in from_dist
req, comments = _get_editable_info(dist)
File "C:UserslhottAppDataLocalProgramsPythonPython310libsite-packagespip_internaloperationsfreeze.py", line 164, in _get_editable_info
vcs_backend = vcs.get_backend_for_dir(location)
File "C:UserslhottAppDataLocalProgramsPythonPython310libsite-packagespip_internalvcsversioncontrol.py", line 238, in get_backend_for_dir
repo_path = vcs_backend.get_repository_root(location)
File "C:UserslhottAppDataLocalProgramsPythonPython310libsite-packagespip_internalvcsgit.py", line 501, in get_repository_root
r = cls.run_command(
File "C:UserslhottAppDataLocalProgramsPythonPython310libsite-packagespip_internalvcsversioncontrol.py", line 650, in run_command
return call_subprocess(
File "C:UserslhottAppDataLocalProgramsPythonPython310libsite-packagespip_internalutilssubprocess.py", line 141, in call_subprocess
proc = subprocess.Popen(
File "C:UserslhottAppDataLocalProgramsPythonPython310libsubprocess.py", line 966, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:UserslhottAppDataLocalProgramsPythonPython310libsubprocess.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 have tried restarting my laptop.
- Running the terminal with administrators privileges.
Answers:
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.
I have actually faced a similar issue in the past that I solved by upgrading PIP
pip install pip --upgrade
Running pip freeze
in the terminal throws the following error (full traceback):
PS C:Userslhott> pip freeze
ERROR: Exception:
Traceback (most recent call last):
File "C:UserslhottAppDataLocalProgramsPythonPython310libsite-packagespip_internalclibase_command.py", line 167, in exc_logging_wrapper
status = run_func(*args)
File "C:UserslhottAppDataLocalProgramsPythonPython310libsite-packagespip_internalcommandsfreeze.py", line 87, in run
for line in freeze(
File "C:UserslhottAppDataLocalProgramsPythonPython310libsite-packagespip_internaloperationsfreeze.py", line 43, in freeze
req = FrozenRequirement.from_dist(dist)
File "C:UserslhottAppDataLocalProgramsPythonPython310libsite-packagespip_internaloperationsfreeze.py", line 237, in from_dist
req, comments = _get_editable_info(dist)
File "C:UserslhottAppDataLocalProgramsPythonPython310libsite-packagespip_internaloperationsfreeze.py", line 164, in _get_editable_info
vcs_backend = vcs.get_backend_for_dir(location)
File "C:UserslhottAppDataLocalProgramsPythonPython310libsite-packagespip_internalvcsversioncontrol.py", line 238, in get_backend_for_dir
repo_path = vcs_backend.get_repository_root(location)
File "C:UserslhottAppDataLocalProgramsPythonPython310libsite-packagespip_internalvcsgit.py", line 501, in get_repository_root
r = cls.run_command(
File "C:UserslhottAppDataLocalProgramsPythonPython310libsite-packagespip_internalvcsversioncontrol.py", line 650, in run_command
return call_subprocess(
File "C:UserslhottAppDataLocalProgramsPythonPython310libsite-packagespip_internalutilssubprocess.py", line 141, in call_subprocess
proc = subprocess.Popen(
File "C:UserslhottAppDataLocalProgramsPythonPython310libsubprocess.py", line 966, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:UserslhottAppDataLocalProgramsPythonPython310libsubprocess.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 have tried restarting my laptop.
- Running the terminal with administrators privileges.
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.
I have actually faced a similar issue in the past that I solved by upgrading PIP
pip install pip --upgrade