点子版本:23.1.1
Python版本:3.9.11
操作系统:Windows 11
我的python项目已创建,并使用env作为虚拟环境。 psycopg2 安装失败。 根据日志,“psycopg2 的构建轮失败”,并且还显示“不推荐使用许可证文件参数”。
即使其他平台存在解决方案,我也没有找到适合我的平台的任何解决方案。 滚轮和设置工具都是最新的。
pip install psycopg2-binary
也不起作用。
完整错误如下:
(env) PS C:\\Aavash files\\COMP206\\Project\\Movie4AllMoods\> pip install psycopg2
Collecting psycopg2
Using cached psycopg2-2.9.6.tar.gz (383 kB)
Preparing metadata (setup.py) ... done
Building wheels for collected packages: psycopg2
Building wheel for psycopg2 (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─\> \[34 lines of output\]
C:\\Aavash files\\COMP206\\Project\\Movie4AllMoods\\env\\lib\\python3.9\\site-packages\\setuptools\\config\\setupcfg.py:293: \_DeprecatedConfig: Deprecated config in `setup.cfg`
!!
********************************************************************************
The license_file parameter is deprecated, use license_files instead.
By 2023-Oct-30, you need to update your project and remove deprecated calls
or your builds will no longer be supported.
See https://setuptools.pypa.io/en/latest/https://setuptools.pypa.io/en/latest/userguide/declarative_config.html for details.
********************************************************************************
!!
parsed = self.parsers.get(option_name, lambda x: x)(value)
running bdist_wheel
running build
running build_py
creating build
creating build\lib.mingw_x86_64-cpython-39
creating build\lib.mingw_x86_64-cpython-39\psycopg2
copying lib\errorcodes.py -> build\lib.mingw_x86_64-cpython-39\psycopg2
copying lib\errors.py -> build\lib.mingw_x86_64-cpython-39\psycopg2
copying lib\extensions.py -> build\lib.mingw_x86_64-cpython-39\psycopg2
copying lib\extras.py -> build\lib.mingw_x86_64-cpython-39\psycopg2
copying lib\pool.py -> build\lib.mingw_x86_64-cpython-39\psycopg2
copying lib\sql.py -> build\lib.mingw_x86_64-cpython-39\psycopg2
copying lib\tz.py -> build\lib.mingw_x86_64-cpython-39\psycopg2
copying lib\_ipaddress.py -> build\lib.mingw_x86_64-cpython-39\psycopg2
copying lib\_json.py -> build\lib.mingw_x86_64-cpython-39\psycopg2
copying lib\_range.py -> build\lib.mingw_x86_64-cpython-39\psycopg2
copying lib\__init__.py -> build\lib.mingw_x86_64-cpython-39\psycopg2
running build_ext
building 'psycopg2._psycopg' extension
error: --plat-name must be one of ('win32', 'win-amd64', 'win-arm32', 'win-arm64')
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for psycopg2
Running setup.py clean for psycopg2
Failed to build psycopg2
ERROR: Could not build wheels for psycopg2, which is required to install pyproject.toml-based projects
我尝试过更新 pip、wheel 和设置工具,但没有成功。我发现的其他所有内容都是我无法运行的 Linux 命令。它在全局中安装良好,但在我的虚拟环境中显示错误。我已经尝试了一切,但似乎没有任何效果。
就我而言,我必须走那条路
C:\msys64\mingw64\lib\python3.9\site-packages\setuptools\_distutils
发生错误的地方。在你的情况下,它必须是路径
C:\Aavash files\COMP206\Project\Movie4AllMoods\env\lib\python3.9\site-packages\setuptools\config\setupcfg.py
打开文件时,在该文件中搜索变量
plat_name
。
你会发现这样的代码块:
`def __init__(self, verbose=0, dry_run=0, force=0):
super().__init__(verbose, dry_run, force)
# target platform (.plat_name is consistent with 'bdist')
self.plat_name = None
self.initialized = False`
将
None
中的self.plat_name
更改为您平台的版本,如果是64位系统则为'win-arm64'
,如果您的设备有AMD处理器则为'win-amd64'
。
您可以检查该文件中的
PLAT_TO_VCVARS
变量,它将列出所有可用的平台。
`PLAT_TO_VCVARS = {
'win32' : 'x86',
'win-amd64' : 'x86_amd64',
'win-arm32' : 'x86_arm',
'win-arm64' : 'x86_arm64'
}`
再次搜索
plat_name
,你会发现这样的代码块:
`def initialize(self, plat_name=None):
# multi-init means we would need to check platform same each time...
assert not self.initialized, "don't init multiple times"
if plat_name is None:
plat_name = get_platform()
# sanity check for platforms to prevent obscure errors later.
if plat_name not in PLAT_TO_VCVARS:
raise DistutilsPlatformError("--plat-name must be one of {}"
.format(tuple(PLAT_TO_VCVARS)))
# Get the vcvarsall.bat spec for the requested platform.
plat_spec = PLAT_TO_VCVARS[plat_name]`
将
None
中的plat_name = None
更改为您的平台名称,在我的例子中,它是'win-amd64'
。
执行此操作,希望您的错误能够得到解决。
msys2 用户还可以从以下线程的评论之一中受益。
https://github.com/pyproj4/pyproj/issues/1009
SETUPTOOLS_USE_DISTUTILS=stdlib pip install <your package name>
如 github 票证中所述
据我收集的信息:由于 setuptools>=60.0.0 setuptools“包括 distutils 的本地供应副本”。因此,除非您制作,否则不会使用标准库 distutils 的 MSYS2 修补版本