无法安装 flask-mongoengine

Unable to install flask-mongoengine

尝试在使用 WSL2/Debian 的 Win10 计算机上安装 flask-mongoengine 时出现错误。能够毫无问题地安装其他项目依赖项。

输入的命令是:python3 -m pip install flask-mongoengine,错误输出如下)

已尝试使用 sudo 进行类似操作,但没有任何改进。

    Collecting flask-mongoengine
      Using cached flask-mongoengine-0.9.5.tar.gz (111 kB)
        ERROR: Command errored out with exit status 1:
         command: /mnt/d/dev/opalapi/venv/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-wl69gb5c/flask-mongoengine/setup.py'"'"'; __file__='"'"'/tmp/pip-install-wl69gb5c/flask-mongoengine/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-ldtngp0q
             cwd: /tmp/pip-install-wl69gb5c/flask-mongoengine/
        Complete output (44 lines):
        WARNING: The wheel package is not available.
          ERROR: Command errored out with exit status 1:
           command: /mnt/d/dev/opalapi/venv/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-wheel-l5ep1tsz/rednose/setup.py'"'"'; __file__='"'"'/tmp/pip-wheel-l5ep1tsz/rednose/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-w93yg6mf
               cwd: /tmp/pip-wheel-l5ep1tsz/rednose/
          Complete output (6 lines):
          usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
             or: setup.py --help [cmd1 cmd2 ...]
             or: setup.py --help-commands
             or: setup.py cmd --help
    
          error: invalid command 'bdist_wheel'
          ----------------------------------------
          ERROR: Failed building wheel for rednose
        ERROR: Failed to build one or more wheels
        Traceback (most recent call last):
          File "/mnt/d/dev/opalapi/venv/lib/python3.8/site-packages/setuptools/installer.py", line 128, in fetch_build_egg
            subprocess.check_call(cmd)
          File "/usr/local/lib/python3.8/subprocess.py", line 364, in check_call
            raise CalledProcessError(retcode, cmd)
        subprocess.CalledProcessError: Command '['/mnt/d/dev/opalapi/venv/bin/python3', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/tmp/tmpleem7stb', '--quiet', 'rednose']' returned non-zero exit status 1.
    
        During handling of the above exception, another exception occurred:
    
        Traceback (most recent call last):
          File "<string>", line 1, in <module>
          File "/tmp/pip-install-wl69gb5c/flask-mongoengine/setup.py", line 36, in <module>
            setup(
          File "/mnt/d/dev/opalapi/venv/lib/python3.8/site-packages/setuptools/__init__.py", line 143, in setup
            _install_setup_requires(attrs)
          File "/mnt/d/dev/opalapi/venv/lib/python3.8/site-packages/setuptools/__init__.py", line 138, in _install_setup_requires
            dist.fetch_build_eggs(dist.setup_requires)
          File "/mnt/d/dev/opalapi/venv/lib/python3.8/site-packages/setuptools/dist.py", line 695, in fetch_build_eggs
            resolved_dists = pkg_resources.working_set.resolve(
          File "/mnt/d/dev/opalapi/venv/lib/python3.8/site-packages/pkg_resources/__init__.py", line 781, in resolve
            dist = best[req.key] = env.best_match(
          File "/mnt/d/dev/opalapi/venv/lib/python3.8/site-packages/pkg_resources/__init__.py", line 1066, in best_match
            return self.obtain(req, installer)
          File "/mnt/d/dev/opalapi/venv/lib/python3.8/site-packages/pkg_resources/__init__.py", line 1078, in obtain
            return installer(requirement)
          File "/mnt/d/dev/opalapi/venv/lib/python3.8/site-packages/setuptools/dist.py", line 754, in fetch_build_egg
            return fetch_build_egg(self, req)
          File "/mnt/d/dev/opalapi/venv/lib/python3.8/site-packages/setuptools/installer.py", line 130, in fetch_build_egg
            raise DistutilsError(str(e))
        distutils.errors.DistutilsError: Command '['/mnt/d/dev/opalapi/venv/bin/python3', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', '/tmp/tmpleem7stb', '--quiet', 'rednose']' returned non-zero exit status 1.
        ----------------------------------------
    ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.```

错误信息error: invalid command 'bdist_wheel'表示,Python找不到wheel模块。先按 pip install wheel 安装 wheel 模块,然后 pip install flask-mongoengine.

很明显是wheel的问题,因为你的系统没有安装wheel。

Wheel 是一种比每次都从源代码重新构建更快、更可靠的安装 Python 软件的方法。

使用这个命令

pip install wheel flask-mongoengine

如果您正在使用 python3 而不是默认 python 则使用

pip3 install wheel flask-mongoengine