Building wheel for pandas (setup.py)...耗时长解决方法

针对Python3.8环境下安装pandas0.24.2和0.23.0版本时出现的长时间未完成情况,文章提出了更换pandas版本作为解决方案。参考提供的链接,用户可以找到更多关于如何快速安装不同版本pandas的建议。
部署运行你感兴趣的模型镜像

问题描述

Python 3.8,安装pandas==0.24.2及0.23.0时间过久

解决方法

更换pandas版本
在这里插入图片描述

参考:https://qa.1r1g.com/sf/ask/4401979361/

您可能感兴趣的与本文相关的镜像

Python3.10

Python3.10

Conda
Python

Python 是一种高级、解释型、通用的编程语言,以其简洁易读的语法而闻名,适用于广泛的应用,包括Web开发、数据分析、人工智能和自动化脚本

C:\Users\Administrator\PyCharmMiscProject\.venv\Scripts\python.exe D:/Program Files/JetBrains/PyCharm 2025.2.3/plugins/python-ce/helpers/packaging_tool.py install cupy Collecting cupy Using cached cupy-13.6.0.tar.gz (3.3 MB) Installing build dependencies: started Installing build dependencies: finished with status 'done' Getting requirements to build wheel: started Getting requirements to build wheel: finished with status 'done' Preparing metadata (pyproject.toml): started Preparing metadata (pyproject.toml): finished with status 'done' Requirement already satisfied: numpy<2.6,>=1.22 in c:\users\administrator\pycharmmiscproject\.venv\lib\site-packages (from cupy) (2.3.4) Collecting fastrlock>=0.5 (from cupy) Using cached fastrlock-0.8.3-cp312-cp312-win_amd64.whl.metadata (7.9 kB) Using cached fastrlock-0.8.3-cp312-cp312-win_amd64.whl (31 kB) Building wheels for collected packages: cupy Building wheel for cupy (pyproject.toml): started Building wheel for cupy (pyproject.toml): finished with status 'error' Failed to build cupy error: subprocess-exited-with-error Building wheel for cupy (pyproject.toml) did not run successfully. exit code: 1 [73 lines of output] Clearing directory: C:\Users\Administrator\AppData\Local\Temp\pip-install-51_3qmlh\cupy_8ad1d1feb8f74bcd9b3c395c1deddc99\cupy\.data Generating CUPY_CACHE_KEY from header files... CUPY_CACHE_KEY (1717 files matching C:\Users\Administrator\AppData\Local\Temp\pip-install-51_3qmlh\cupy_8ad1d1feb8f74bcd9b3c395c1deddc99\cupy\_core\include\**): 0bb7da13cbc36729b5a184678063e5ebaecfdde7 Looking for NVTX from: ['C:\\Program Files\\NVIDIA Corporation\\Nsight Systems 2025.3.2\\target-windows-x64\\nvtx'] Using NVTX at: C:\Program Files\NVIDIA Corporation\Nsight Systems 2025.3.2\target-windows-x64\nvtx -------- Configuring Module: cuda -------- Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/ ************************************************** *** WARNING: Cannot check compute capability Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/ ************************************************** ************************************************************ * CuPy Configuration Summary * ************************************************************ Build Environment: Include directories: ['C:\\Users\\Administrator\\AppData\\Local\\Temp\\pip-install-51_3qmlh\\cupy_8ad1d1feb8f74bcd9b3c395c1deddc99\\cupy/_core/include\\cupy/_cccl/libcudacxx', 'C:\\Users\\Administrator\\AppData\\Local\\Temp\\pip-install-51_3qmlh\\cupy_8ad1d1feb8f74bcd9b3c395c1deddc99\\cupy/_core/include\\cupy/_cccl/thrust', 'C:\\Users\\Administrator\\AppData\\Local\\Temp\\pip-install-51_3qmlh\\cupy_8ad1d1feb8f74bcd9b3c395c1deddc99\\cupy/_core/include\\cupy/_cccl/cub', 'C:\\Users\\Administrator\\AppData\\Local\\Temp\\pip-install-51_3qmlh\\cupy_8ad1d1feb8f74bcd9b3c395c1deddc99\\cupy/_core/include', 'C:\\Program Files\\NVIDIA Corporation\\Nsight Systems 2025.3.2\\target-windows-x64\\nvtx\\include'] Library directories: [] nvcc command : (not found) hipcc command : (not found) Environment Variables: CFLAGS : (none) LDFLAGS : (none) LIBRARY_PATH : (none) CUDA_PATH : (none) NVCC : (none) HIPCC : (none) ROCM_HOME : (none) Modules: cuda : No -> Include files not found: ['cublas_v2.h', 'cuda.h', 'cuda_profiler_api.h', 'cuda_runtime.h', 'cufft.h', 'curand.h', 'cusparse.h'] -> Check your CFLAGS environment variable. ERROR: CUDA could not be found on your system. HINT: You are trying to build CuPy from source, which is NOT recommended for general use. Please consider using binary packages instead. Please refer to the Installation Guide for details: https://docs.cupy.dev/en/stable/install.html ************************************************************ Traceback (most recent call last): File "C:\Users\Administrator\PyCharmMiscProject\.venv\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 389, in <module> main() File "C:\Users\Administrator\PyCharmMiscProject\.venv\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 373, in main json_out["return_val"] = hook(**hook_input["kwargs"]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Administrator\PyCharmMiscProject\.venv\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 280, in build_wheel return _build_backend().build_wheel( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-sqtmjs6t\overlay\Lib\site-packages\setuptools\build_meta.py", line 435, in build_wheel return _build(['bdist_wheel', '--dist-info-dir', str(metadata_directory)]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-sqtmjs6t\overlay\Lib\site-packages\setuptools\build_meta.py", line 423, in _build return self._build_with_temp_dir( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-sqtmjs6t\overlay\Lib\site-packages\setuptools\build_meta.py", line 404, in _build_with_temp_dir self.run_setup() File "C:\Users\Administrator\AppData\Local\Temp\pip-build-env-sqtmjs6t\overlay\Lib\site-packages\setuptools\build_meta.py", line 317, in run_setup exec(code, locals()) File "<string>", line 59, in <module> File "C:\Users\Administrator\AppData\Local\Temp\pip-install-51_3qmlh\cupy_8ad1d1feb8f74bcd9b3c395c1deddc99\install\cupy_builder\cupy_setup_build.py", line 562, in get_ext_modules extensions = make_extensions(ctx, compiler, use_cython) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Administrator\AppData\Local\Temp\pip-install-51_3qmlh\cupy_8ad1d1feb8f74bcd9b3c395c1deddc99\install\cupy_builder\cupy_setup_build.py", line 403, in make_extensions raise Exception('Your CUDA environment is invalid. ' Exception: Your CUDA environment is invalid. Please check above error log. [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for cupy [notice] A new release of pip is available: 25.1.1 -> 25.3 [notice] To update, run: python.exe -m pip install --upgrade pip ERROR: Failed to build installable wheels for some pyproject.toml based projects (cupy) Process finished with exit code 1
最新发布
11-17
<think>好的,用户想知道如何为pandas构建wheel文件,特别是使用pyproject.toml的情况。首先,我需要回忆一下Python打包的相关知识。wheel文件是预构建的二进制包,可以加快安装速度,尤其是在有C扩展的情况下,比如pandas。用户可能遇到需要从源码构建的情况,或者想自定义某些功能。 接下来,我应该考虑现代Python打包主要使用pyproject.toml,取代了旧的setup.py。所以用户的问题核心是如何配置pyproject.toml来构建pandaswheel。但pandas本身可能已经提供了这个文件,用户可能需要从官方仓库获取源码。 首先,用户需要安装构建工具,比如build。然后,从pandas的GitHub仓库克隆代码,切换到稳定分支,比如v2.2.2。接着,确保依赖项都安装正确,特别是可能需要的系统库,比如NumPy。然后使用python -m build命令生成wheel文件,这会在dist目录下生成.whl文件。 用户可能遇到的问题包括缺少依赖项,比如C编译器的依赖,或者构建过程中出现的错误。比如,在Windows上可能需要安装Visual Studio Build Tools,Linux上可能需要gcc和Python开发头文件。此外,构建pandas可能需要一些时间,特别是第一次构建的时候,因为需要编译C扩展。 另外,用户可能对构建后的测试感兴趣,所以应该建议安装生成的wheel文件,并运行pandas的测试套件,确保一切正常。最后,可能需要提到如何解决常见问题,比如依赖问题或构建失败的情况,建议查看官方文档或社区支持。 需要检查是否有遗漏的步骤,比如是否需要先安装setuptools或wheel包,不过build工具应该会自动处理这些。同时,确保用户使用的是最新版本的pip和setuptools,避免兼容性问题。最后,总结步骤,保持清晰,分点说明,方便用户逐步操作。</think>### 如何通过`pyproject.toml`为pandas构建wheel文件 #### 步骤说明 1. **安装构建工具** 先安装Python官方推荐的构建工具`build`: ```bash pip install build ``` 此工具会自动处理`pyproject.toml`中的配置[^1]。 2. **获取pandas源码** 从pandas官方仓库克隆代码并切换到稳定分支: ```bash git clone https://github.com/pandas-dev/pandas.git cd pandas git checkout v2.2.2 # 替换为最新稳定版本 ``` 3. **检查构建配置** pandas官方仓库已包含完整的`pyproject.toml`,内容示例如下: ```toml [build-system] requires = ["setuptools>=64.0.0", "wheel", "Cython>=3", "numpy>=1.22.4"] build-backend = "setuptools.build_meta" ``` 该配置声明了构建依赖项(Cython、numpy等)[^2]。 4. **执行构建命令** ```bash python -m build --wheel ``` 构建过程会自动: - 创建虚拟环境 - 安装构建依赖 - 编译C扩展 - 生成`.whl`文件到`dist/`目录 5. **验证生成文件** 构建完成后会生成类似`pandas-2.2.2-cp310-cp310-manylinux_2_17_x86_64.whl`的文件,可通过以下命令安装测试: ```bash pip install dist/pandas-*.whl ``` #### 常见问题解决 - **缺少系统依赖** 在Linux上需安装开发工具链: ```bash sudo apt-get install build-essential python3-dev ``` - **Cython版本问题** 若出现`Cython.Compiler.Errors.CompileError`,可尝试升级Cython: ```bash pip install --upgrade Cython ``` - **内存不足** 编译大型C扩展时建议关闭其他内存密集型应用,或使用交换分区扩展内存[^3]。 #### 构建优化建议 - 通过环境变量加速C编译: ```bash export CFLAGS="-O3 -march=native" ``` - 使用`-C=--global-option=--parallel`启用多核编译: ```bash python -m build --wheel -C=--global-option=--parallel ```
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值