You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Python Flask推荐系统部署与surprise库安装问题求助

问题描述

我使用Python 3.9.2结合surprise库开发了一套推荐系统,并基于Flask搭建了演示网站,目前遇到两个核心问题:

Python 3.9 + Apache部署出现7024函数错误

将Python 3.9版本的Flask应用部署到Apache服务器时,出现7024错误(函数错误),尚未找到可行的解决方案。

Python 3.12安装surprise库失败

改用Python 3.12按相同步骤部署可正常运行,但推荐功能因未安装surprise库报错。尝试安装时触发如下错误:

Collecting surprise
  Using cached surprise-0.1-py2.py3-none-any.whl.metadata (327 bytes)
Collecting scikit-surprise (from surprise)
  Using cached scikit-surprise-1.1.3.tar.gz (771 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [60 lines of output]
      <string>:65: _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`.
              ********************************************************************************    
      
      !!
      WARNING: The wheel package is not available.
      D:\flaskApp\env\Scripts\python.exe: No module named pip
      Traceback (most recent call last):
        File "C:\Users\user\AppData\Local\Temp\pip-build-env-kkvji2sx\overlay\Lib\site-packages\setuptools\installer.py", line 101, in _fetch_build_egg_no_warn
          subprocess.check_call(cmd)
        File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.12_3.12.752.0_x64__qbz5n2kfra8p0\Lib\subprocess.py", line 413, in check_call
          raise CalledProcessError(retcode, cmd)
      subprocess.CalledProcessError: Command '['D:\\flaskApp\\env\\Scripts\\python.exe', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', 'C:\\Users\\user\\AppData\\Local\\Temp\\tmpx2euatq3', '--quiet', 'numpy>=1.17.3']' returned non-zero exit status 1.
     
      The above exception was the direct cause of the following exception:
     
      Traceback (most recent call last):
        File "D:\flaskApp\env\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
          main()
        File "D:\flaskApp\env\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "D:\flaskApp\env\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 118, in get_requires_for_build_wheel          return hook(config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\user\AppData\Local\Temp\pip-build-env-kkvji2sx\overlay\Lib\site-packages\setuptools\build_meta.py", line 325, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\user\AppData\Local\Temp\pip-build-env-kkvji2sx\overlay\Lib\site-packages\setuptools\build_meta.py", line 295, in _get_build_requires
          self.run_setup()
        File "C:\Users\user\AppData\Local\Temp\pip-build-env-kkvji2sx\overlay\Lib\site-packages\setuptools\build_meta.py", line 487, in run_setup 
          super().run_setup(setup_script=setup_script)
        File "C:\Users\user\AppData\Local\Temp\pip-build-env-kkvji2sx\overlay\Lib\site-packages\setuptools\build_meta.py", line 311, in run_setup 
          exec(code, locals())
        File "<string>", line 65, in <module>
        File "C:\Users\user\AppData\Local\Temp\pip-build-env-kkvji2sx\overlay\Lib\site-packages\setuptools\dist.py", line 640, in fetch_build_eggs          return _fetch_build_eggs(self, requires)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\user\AppData\Local\Temp\pip-build-env-kkvji2sx\overlay\Lib\site-packages\setuptools\installer.py", line 38, in _fetch_build_eggs
          resolved_dists = pkg_resources.working_set.resolve(
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\user\AppData\Local\Temp\pip-build-env-kkvji2sx\overlay\Lib\site-packages\pkg_resources\__init__.py", line 798, in resolve  
          dist = self._resolve_dist(
                 ^^^^^^^^^^^^^^^^^^^
        File "C:\Users\user\AppData\Local\Temp\pip-build-env-kkvji2sx\overlay\Lib\site-packages\pkg_resources\__init__.py", line 834, in _resolve_dist
          dist = best[req.key] = env.best_match(
                                 ^^^^^^^^^^^^^^^
        File "C:\Users\user\AppData\Local\Temp\pip-build-env-kkvji2sx\overlay\Lib\site-packages\pkg_resources\__init__.py", line 1104, in best_match
          return self.obtain(req, installer)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\user\AppData\Local\Temp\pip-build-env-kkvji2sx\overlay\Lib\site-packages\pkg_resources\__init__.py", line 1115, in obtain  
          return installer(requirement) if installer else None
        File "C:\Users\user\AppData\Local\Temp\pip-build-env-kkvji2sx\overlay\Lib\site-packages\setuptools\installer.py", line 103, in _fetch_build_egg_no_warn
          raise DistutilsError(str(e)) from e
      distutils.errors.DistutilsError: Command '['D:\\flaskApp\\env\\Scripts\\python.exe', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', 'C:\\Users\\user\\AppData\\Local\\Temp\\tmpx2euatq3', '--quiet', 'numpy>=1.17.3']' 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: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip

已尝试重新安装Python 3.12、更新pip,但问题仍未解决。


内容的提问来源于stack exchange,提问作者Marwan Ashraf

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.25 20:12:16