鱼C论坛

 找回密码
 立即注册
查看: 69|回复: 1

在conda的干净虚拟环境里 pip install dotenv 却出错,是为啥?

[复制链接]
发表于 2024-12-9 11:07:14 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
dengz@nv2-pc:~/SubtitleSpliter$ pip install dotenv
Collecting dotenv
  Using cached dotenv-0.0.5.tar.gz (2.4 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [76 lines of output]
      /home/dengz/anaconda3/envs/subspliter_py310/lib/python3.10/site-packages/setuptools/__init__.py:94: _DeprecatedInstaller: setuptools.installer and fetch_build_eggs are deprecated.
      !!

              ********************************************************************************
              Requirements should be satisfied by a PEP 517 installer.
              If you are using pip, you can try `pip install --use-pep517`.
              ********************************************************************************

      !!
        dist.fetch_build_eggs(dist.setup_requires)
        error: subprocess-exited-with-error

        × python setup.py egg_info did not run successfully.
        │ exit code: 1
        ╰─> [16 lines of output]
            Traceback (most recent call last):
              File "<string>", line 2, in <module>
              File "<pip-setuptools-caller>", line 14, in <module>
              File "/tmp/pip-wheel-n_t0gdk3/distribute_97c004b4c01a4abc802d38e30486640e/setuptools/__init__.py", line 2, in <module>
                from setuptools.extension import Extension, Library
              File "/tmp/pip-wheel-n_t0gdk3/distribute_97c004b4c01a4abc802d38e30486640e/setuptools/extension.py", line 5, in <module>
                from setuptools.dist import _get_unpatched
              File "/tmp/pip-wheel-n_t0gdk3/distribute_97c004b4c01a4abc802d38e30486640e/setuptools/dist.py", line 7, in <module>
                from setuptools.command.install import install
              File "/tmp/pip-wheel-n_t0gdk3/distribute_97c004b4c01a4abc802d38e30486640e/setuptools/command/__init__.py", line 8, in <module>
                from setuptools.command import install_scripts
              File "/tmp/pip-wheel-n_t0gdk3/distribute_97c004b4c01a4abc802d38e30486640e/setuptools/command/install_scripts.py", line 3, in <module>
                from pkg_resources import Distribution, PathMetadata, ensure_directory
              File "/tmp/pip-wheel-n_t0gdk3/distribute_97c004b4c01a4abc802d38e30486640e/pkg_resources.py", line 1518, in <module>
                register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
            AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'
            [end of output]

        note: This error originates from a subprocess, and is likely not a problem with pip.
      error: metadata-generation-failed

      × Encountered error while generating package metadata.
      ╰─> See above for output.

      note: This is an issue with the package mentioned above, not pip.
      hint: See above for details.
      Traceback (most recent call last):
        File "/home/dengz/anaconda3/envs/subspliter_py310/lib/python3.10/site-packages/setuptools/installer.py", line 107, in _fetch_build_egg_no_warn
          subprocess.check_call(cmd)
        File "/home/dengz/anaconda3/envs/subspliter_py310/lib/python3.10/subprocess.py", line 369, in check_call
          raise CalledProcessError(retcode, cmd)
      subprocess.CalledProcessError: Command '['/home/dengz/anaconda3/envs/subspliter_py310/bin/python', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/tmp/tmpnnrjrvd_', '--quiet', 'distribute']' returned non-zero exit status 1.

      The above exception was the direct cause of the following exception:

      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-jr2_nbtp/dotenv_71c51d804bbd498985771d470d8609d9/setup.py", line 13, in <module>
          setup(name='dotenv',
        File "/home/dengz/anaconda3/envs/subspliter_py310/lib/python3.10/site-packages/setuptools/__init__.py", line 116, in setup
          _install_setup_requires(attrs)
        File "/home/dengz/anaconda3/envs/subspliter_py310/lib/python3.10/site-packages/setuptools/__init__.py", line 89, in _install_setup_requires
          _fetch_build_eggs(dist)
        File "/home/dengz/anaconda3/envs/subspliter_py310/lib/python3.10/site-packages/setuptools/__init__.py", line 94, in _fetch_build_eggs
          dist.fetch_build_eggs(dist.setup_requires)
        File "/home/dengz/anaconda3/envs/subspliter_py310/lib/python3.10/site-packages/setuptools/dist.py", line 659, in fetch_build_eggs
          return _fetch_build_eggs(self, requires)
        File "/home/dengz/anaconda3/envs/subspliter_py310/lib/python3.10/site-packages/setuptools/installer.py", line 44, in _fetch_build_eggs
          resolved_dists = pkg_resources.working_set.resolve(
        File "/home/dengz/anaconda3/envs/subspliter_py310/lib/python3.10/site-packages/pkg_resources/__init__.py", line 892, in resolve
          dist = self._resolve_dist(
        File "/home/dengz/anaconda3/envs/subspliter_py310/lib/python3.10/site-packages/pkg_resources/__init__.py", line 928, in _resolve_dist
          dist = best[req.key] = env.best_match(
        File "/home/dengz/anaconda3/envs/subspliter_py310/lib/python3.10/site-packages/pkg_resources/__init__.py", line 1266, in best_match
          return self.obtain(req, installer)
        File "/home/dengz/anaconda3/envs/subspliter_py310/lib/python3.10/site-packages/pkg_resources/__init__.py", line 1302, in obtain
          return installer(requirement) if installer else None
        File "/home/dengz/anaconda3/envs/subspliter_py310/lib/python3.10/site-packages/setuptools/installer.py", line 109, in _fetch_build_egg_no_warn
          raise DistutilsError(str(e)) from e
      distutils.errors.DistutilsError: Command '['/home/dengz/anaconda3/envs/subspliter_py310/bin/python', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/tmp/tmpnnrjrvd_', '--quiet', 'distribute']' returned non-zero exit status 1.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2024-12-9 11:07:20 | 显示全部楼层
您遇到的问题是因为安装的 `dotenv` 包存在一些问题。实际上,您很可能需要的是 `python-dotenv` 包,而不是 `dotenv` 包。`python-dotenv` 用于读取 `.env` 文件中的环境变量。

请尝试以下步骤来解决问题:

1. 首先,卸载错误安装的 `dotenv` 包(如果已经部分安装):
pip uninstall dotenv

2. 然后,安装正确的 `python-dotenv` 包:
pip install python-dotenv

这样应该可以解决您的安装问题。如果在新环境下有其他安装问题,建议检查 `pip` 和 `setuptools` 是否是最新版本。您可以通过以下命令升级它们:
pip install --upgrade pip setuptools

以上回复来自 FishC AI 小助理,如未能正确解答您的问题,请继续追问。
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-12-22 12:15

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表