tensorflow ModuleNotFoundError:Anaconda提示中没有名为'_distutils_hack'的模块

egdjgwm8  于 2023-08-06  发布在  其他
关注(0)|答案(1)|浏览(124)

我有问题like this。我在anaconda提示符下运行命令

pip uninstall tensorflow absl-py astunparse flatbuffers gast google-pasta grpcio h5py keras keras-preprocessing libclang numpy opt-einsum protobuf setuptools six tensorboard tensorflow-io-gcs-filesystem termcolor tf-estimator-nightly typing-extensions wrapt

字符串
我不能在我的venv中做任何事情,每当我输入命令时,它总是显示如下错误:

Error processing line 1 of D:\virtual_env\face_recognition\lib\site-packages\distutils-precedence.pth:

  Traceback (most recent call last):
    File "D:\virtual_env\face_recognition\lib\site.py", line 169, in addpackage
      exec(line)
    File "<string>", line 1, in <module>
  ModuleNotFoundError: No module named '_distutils_hack'

Remainder of file ignored
ERROR: Exception:
Traceback (most recent call last):
  File "C:\Users\unhas\AppData\Roaming\Python\Python39\site-packages\pip\_internal\cli\base_command.py", line 167, in exc_logging_wrapper
    status = run_func(*args)
  File "C:\Users\unhas\AppData\Roaming\Python\Python39\site-packages\pip\_internal\cli\req_command.py", line 205, in wrapper
    return func(self, options, args)
  File "C:\Users\unhas\AppData\Roaming\Python\Python39\site-packages\pip\_internal\commands\install.py", line 285, in run
    session = self.get_default_session(options)
  File "C:\Users\unhas\AppData\Roaming\Python\Python39\site-packages\pip\_internal\cli\req_command.py", line 75, in get_default_session
    self._session = self.enter_context(self._build_session(options))
  File "C:\Users\unhas\AppData\Roaming\Python\Python39\site-packages\pip\_internal\cli\req_command.py", line 89, in _build_session
    session = PipSession(
  File "C:\Users\unhas\AppData\Roaming\Python\Python39\site-packages\pip\_internal\network\session.py", line 282, in __init__
    self.headers["User-Agent"] = user_agent()
  File "C:\Users\unhas\AppData\Roaming\Python\Python39\site-packages\pip\_internal\network\session.py", line 157, in user_agent
    setuptools_dist = get_default_environment().get_distribution("setuptools")
  File "C:\Users\unhas\AppData\Roaming\Python\Python39\site-packages\pip\_internal\metadata\__init__.py", line 24, in get_default_environment
    from .pkg_resources import Environment
  File "C:\Users\unhas\AppData\Roaming\Python\Python39\site-packages\pip\_internal\metadata\pkg_resources.py", line 9, in <module>
    from pip._vendor import pkg_resources
  File "C:\Users\unhas\AppData\Roaming\Python\Python39\site-packages\pip\_vendor\pkg_resources\__init__.py", line 3252, in <module>
    def _initialize_master_working_set():
  File "C:\Users\unhas\AppData\Roaming\Python\Python39\site-packages\pip\_vendor\pkg_resources\__init__.py", line 3235, in _call_aside
    f(*args, **kwargs)
  File "C:\Users\unhas\AppData\Roaming\Python\Python39\site-packages\pip\_vendor\pkg_resources\__init__.py", line 3277, in _initialize_master_working_set
    tuple(
  File "C:\Users\unhas\AppData\Roaming\Python\Python39\site-packages\pip\_vendor\pkg_resources\__init__.py", line 3278, in <genexpr>
    dist.activate(replace=False)
  File "C:\Users\unhas\AppData\Roaming\Python\Python39\site-packages\pip\_vendor\pkg_resources\__init__.py", line 2785, in activate
    declare_namespace(pkg)
  File "C:\Users\unhas\AppData\Roaming\Python\Python39\site-packages\pip\_vendor\pkg_resources\__init__.py", line 2284, in declare_namespace
    _handle_ns(packageName, path_item)
  File "C:\Users\unhas\AppData\Roaming\Python\Python39\site-packages\pip\_vendor\pkg_resources\__init__.py", line 2217, in _handle_ns
    loader.load_module(packageName)
  File "D:\virtual_env\face_recognition\lib\site-packages\protobuf-3.20.2-py3.9-win-amd64.egg\google\__init__.py", line 1, in <module>
    __import__('pkg_resources').declare_namespace(__name__)
ModuleNotFoundError: No module named 'pkg_resources'


谁能帮我解决这个问题?
当我在anaconda提示符下运行命令时

pip uninstall tensorflow absl-py astunparse flatbuffers gast google-pasta grpcio h5py keras keras-preprocessing libclang numpy opt-einsum protobuf setuptools six tensorboard tensorflow-io-gcs-filesystem termcolor tf-estimator-nightly typing-extensions wrapt


它显示了一些将卸载的模块,如下所示:

Found existing installation: tensorflow 2.9.2
Uninstalling tensorflow-2.9.2:
  Would remove:
    d:\virtual_env\face_recognition\lib\site-packages\tensorflow-2.9.2-py3.9-win-amd64.egg
    d:\virtual_env\face_recognition\scripts\estimator_ckpt_converter-script.py
    d:\virtual_env\face_recognition\scripts\estimator_ckpt_converter.exe
    d:\virtual_env\face_recognition\scripts\import_pb_to_tensorboard-script.py
    d:\virtual_env\face_recognition\scripts\import_pb_to_tensorboard.exe
    d:\virtual_env\face_recognition\scripts\saved_model_cli-script.py
    d:\virtual_env\face_recognition\scripts\saved_model_cli.exe
    d:\virtual_env\face_recognition\scripts\tensorboard.exe
    d:\virtual_env\face_recognition\scripts\tf_upgrade_v2-script.py
    d:\virtual_env\face_recognition\scripts\tf_upgrade_v2.exe
    d:\virtual_env\face_recognition\scripts\tflite_convert-script.py
    d:\virtual_env\face_recognition\scripts\tflite_convert.exe
    d:\virtual_env\face_recognition\scripts\toco-script.py
    d:\virtual_env\face_recognition\scripts\toco.exe
    d:\virtual_env\face_recognition\scripts\toco_from_protos-script.py
    d:\virtual_env\face_recognition\scripts\toco_from_protos.exe
Proceed (Y/n)? Y
  Successfully uninstalled tensorflow-2.9.2
WARNING: Ignoring invalid distribution -rotobuf (d:\virtual_env\face_recognition\lib\site-packages)
Found existing installation: absl-py 1.2.0
Uninstalling absl-py-1.2.0:
  Would remove:
    d:\virtual_env\face_recognition\lib\site-packages\absl_py-1.2.0-py3.9.egg
Proceed (Y/n)? Y
  Successfully uninstalled absl-py-1.2.0
WARNING: Ignoring invalid distribution -rotobuf (d:\virtual_env\face_recognition\lib\site-packages)
Found existing installation: astunparse 1.6.3
Uninstalling astunparse-1.6.3:
  Would remove:
    d:\virtual_env\face_recognition\lib\site-packages\astunparse-1.6.3.dist-info\*
    d:\virtual_env\face_recognition\lib\site-packages\astunparse\*
Proceed (Y/n)? Y
  Successfully uninstalled astunparse-1.6.3
WARNING: Ignoring invalid distribution -rotobuf (d:\virtual_env\face_recognition\lib\site-packages)
Found existing installation: flatbuffers 1.12
Uninstalling flatbuffers-1.12:
  Would remove:
    d:\virtual_env\face_recognition\lib\site-packages\flatbuffers-1.12.dist-info\*
    d:\virtual_env\face_recognition\lib\site-packages\flatbuffers\*
Proceed (Y/n)? Y
  Successfully uninstalled flatbuffers-1.12
WARNING: Ignoring invalid distribution -rotobuf (d:\virtual_env\face_recognition\lib\site-packages)
Found existing installation: gast 0.4.0
Uninstalling gast-0.4.0:
  Would remove:
    d:\virtual_env\face_recognition\lib\site-packages\gast-0.4.0.dist-info\*
    d:\virtual_env\face_recognition\lib\site-packages\gast\*
Proceed (Y/n)? Y
  Successfully uninstalled gast-0.4.0
WARNING: Ignoring invalid distribution -rotobuf (d:\virtual_env\face_recognition\lib\site-packages)
Found existing installation: google-pasta 0.2.0
Uninstalling google-pasta-0.2.0:
  Would remove:
    d:\virtual_env\face_recognition\lib\site-packages\google_pasta-0.2.0.dist-info\*
    d:\virtual_env\face_recognition\lib\site-packages\pasta\*
Proceed (Y/n)? Y
  Successfully uninstalled google-pasta-0.2.0
WARNING: Ignoring invalid distribution -rotobuf (d:\virtual_env\face_recognition\lib\site-packages)
Found existing installation: grpcio 1.48.1
Uninstalling grpcio-1.48.1:
  Would remove:
    d:\virtual_env\face_recognition\lib\site-packages\grpc\*
    d:\virtual_env\face_recognition\lib\site-packages\grpcio-1.48.1.dist-info\*
Proceed (Y/n)? Y
  Successfully uninstalled grpcio-1.48.1
WARNING: Ignoring invalid distribution -rotobuf (d:\virtual_env\face_recognition\lib\site-packages)
Found existing installation: h5py 3.7.0
Uninstalling h5py-3.7.0:
  Would remove:
    d:\virtual_env\face_recognition\lib\site-packages\h5py-3.7.0.dist-info\*
    d:\virtual_env\face_recognition\lib\site-packages\h5py\*
Proceed (Y/n)? Y
  Successfully uninstalled h5py-3.7.0
WARNING: Ignoring invalid distribution -rotobuf (d:\virtual_env\face_recognition\lib\site-packages)
Found existing installation: keras 2.9.0
Uninstalling keras-2.9.0:
  Would remove:
    d:\virtual_env\face_recognition\lib\site-packages\keras-2.9.0.dist-info\*
    d:\virtual_env\face_recognition\lib\site-packages\keras\*
Proceed (Y/n)? Y
  Successfully uninstalled keras-2.9.0
WARNING: Ignoring invalid distribution -rotobuf (d:\virtual_env\face_recognition\lib\site-packages)
Found existing installation: Keras-Preprocessing 1.1.2
Uninstalling Keras-Preprocessing-1.1.2:
  Would remove:
    d:\virtual_env\face_recognition\lib\site-packages\keras_preprocessing-1.1.2.dist-info\*
    d:\virtual_env\face_recognition\lib\site-packages\keras_preprocessing\*
Proceed (Y/n)? Y
  Successfully uninstalled Keras-Preprocessing-1.1.2
Found existing installation: libclang 13.0.0
Uninstalling libclang-13.0.0:
  Would remove:
    c:\users\unhas\appdata\roaming\python\python39\site-packages\clang\*
    c:\users\unhas\appdata\roaming\python\python39\site-packages\libclang-13.0.0.dist-info\*
Proceed (Y/n)? Y
  Successfully uninstalled libclang-13.0.0
WARNING: Ignoring invalid distribution -rotobuf (d:\virtual_env\face_recognition\lib\site-packages)
Found existing installation: numpy 1.21.5
Uninstalling numpy-1.21.5:
  Would remove:
    d:\virtual_env\face_recognition\lib\site-packages\numpy-1.21.5.dist-info\*
    d:\virtual_env\face_recognition\lib\site-packages\numpy\*
    d:\virtual_env\face_recognition\scripts\f2py-script.py
    d:\virtual_env\face_recognition\scripts\f2py.exe
Proceed (Y/n)? Y
  Successfully uninstalled numpy-1.21.5
WARNING: Ignoring invalid distribution -rotobuf (d:\virtual_env\face_recognition\lib\site-packages)
Found existing installation: opt-einsum 3.3.0
Uninstalling opt-einsum-3.3.0:
  Would remove:
    d:\virtual_env\face_recognition\lib\site-packages\opt_einsum-3.3.0.dist-info\*
    d:\virtual_env\face_recognition\lib\site-packages\opt_einsum\*
Proceed (Y/n)? Y
  Successfully uninstalled opt-einsum-3.3.0
WARNING: Ignoring invalid distribution -rotobuf (d:\virtual_env\face_recognition\lib\site-packages)
Found existing installation: protobuf 3.20.0
Uninstalling protobuf-3.20.0:
  Would remove:
    d:\virtual_env\face_recognition\lib\site-packages\google\protobuf\*
    d:\virtual_env\face_recognition\lib\site-packages\protobuf-3.20.0-py3.9-nspkg.pth
    d:\virtual_env\face_recognition\lib\site-packages\protobuf-3.20.0.dist-info\*
Proceed (Y/n)? Y
  Successfully uninstalled protobuf-3.20.0
WARNING: Ignoring invalid distribution -rotobuf (d:\virtual_env\face_recognition\lib\site-packages)
Found existing installation: setuptools 65.3.0
Uninstalling setuptools-65.3.0:
  Would remove:
    d:\virtual_env\face_recognition\lib\site-packages\_distutils_hack
    d:\virtual_env\face_recognition\lib\site-packages\pkg_resources
    d:\virtual_env\face_recognition\lib\site-packages\setuptools
    d:\virtual_env\face_recognition\lib\site-packages\setuptools-65.3.0-py3.10.egg-info
Proceed (Y/n)? Y
  Successfully uninstalled setuptools-65.3.0
WARNING: Ignoring invalid distribution -rotobuf (d:\virtual_env\face_recognition\lib\site-packages)
Found existing installation: six 1.16.0
Uninstalling six-1.16.0:
  Would remove:
    d:\virtual_env\face_recognition\lib\site-packages\six-1.16.0.dist-info\*
    d:\virtual_env\face_recognition\lib\site-packages\six.py
Proceed (Y/n)? Y
  Successfully uninstalled six-1.16.0
WARNING: Ignoring invalid distribution -rotobuf (d:\virtual_env\face_recognition\lib\site-packages)
Found existing installation: tensorboard 2.9.1
Uninstalling tensorboard-2.9.1:
  Would remove:
    d:\virtual_env\face_recognition\lib\site-packages\tensorboard-2.9.1.dist-info\*
    d:\virtual_env\face_recognition\lib\site-packages\tensorboard\*
Proceed (Y/n)? Y
  Successfully uninstalled tensorboard-2.9.1
Found existing installation: tensorflow-io-gcs-filesystem 0.24.0
Uninstalling tensorflow-io-gcs-filesystem-0.24.0:
  Would remove:
    c:\users\unhas\appdata\roaming\python\python39\site-packages\tensorflow_io_gcs_filesystem-0.24.0.dist-info\*
    c:\users\unhas\appdata\roaming\python\python39\site-packages\tensorflow_io_gcs_filesystem\*
Proceed (Y/n)? Y
  Successfully uninstalled tensorflow-io-gcs-filesystem-0.24.0
WARNING: Ignoring invalid distribution -rotobuf (d:\virtual_env\face_recognition\lib\site-packages)
Found existing installation: termcolor 2.0.1
Uninstalling termcolor-2.0.1:
  Would remove:
    d:\virtual_env\face_recognition\lib\site-packages\termcolor-2.0.1.dist-info\*
    d:\virtual_env\face_recognition\lib\site-packages\termcolor\*
Proceed (Y/n)? Y
  Successfully uninstalled termcolor-2.0.1
Found existing installation: tf-estimator-nightly 2.8.0.dev2021122109
Uninstalling tf-estimator-nightly-2.8.0.dev2021122109:
  Would remove:
    c:\users\unhas\appdata\roaming\python\python39\site-packages\tensorflow_estimator\*
    c:\users\unhas\appdata\roaming\python\python39\site-packages\tf_estimator_nightly-2.8.0.dev2021122109.dist-info\*
Proceed (Y/n)? Y
  Successfully uninstalled tf-estimator-nightly-2.8.0.dev2021122109
WARNING: Ignoring invalid distribution -rotobuf (d:\virtual_env\face_recognition\lib\site-packages)
Found existing installation: typing_extensions 4.3.0
Uninstalling typing_extensions-4.3.0:
  Would remove:
    d:\virtual_env\face_recognition\lib\site-packages\typing_extensions-4.3.0.dist-info\*
    d:\virtual_env\face_recognition\lib\site-packages\typing_extensions.py
Proceed (Y/n)? Y
  Successfully uninstalled typing_extensions-4.3.0
WARNING: Ignoring invalid distribution -rotobuf (d:\virtual_env\face_recognition\lib\site-packages)
Found existing installation: wrapt 1.14.1
Uninstalling wrapt-1.14.1:
  Would remove:
    d:\virtual_env\face_recognition\lib\site-packages\wrapt-1.14.1.dist-info\*
    d:\virtual_env\face_recognition\lib\site-packages\wrapt\*
Proceed (Y/n)? Y
  Successfully uninstalled wrapt-1.14.1


我试过this solution,但它仍然相同的错误

1sbrub3j

1sbrub3j1#

尝试在Anaconda提示符中使用此命令

一月一日

如果它显示一个消息,就像它已经满足,然后尝试使用这一个

pip install --upgrade setuptoolspip install --force--reinstall -U setuptools

相关问题