Catalogue
-
从pandas的GitHub上克隆源码;
-
使用源码目录里面的
environment.yml建立一个新env;(否则会破坏现有环境,因为pandas编译要设很多临时环境变量);1
conda env create --file environment.yml
这会自动创建名为
pandas-dev的环境并安装所需依赖,但还差一个meson,切换到pandas-dev,使用如下命令安装:1
2conda activate pandas-dev
conda install meson-python -
切换到克隆下来的源码目录,运行
1
2
3
4
5# Build and install pandas
# By default, this will print verbose output
# showing the "rebuild" taking place on import (see section below for explanation)
# If you do not want to see this, omit everything after --no-build-isolation
python -m pip install -ve . --no-build-isolation -Ceditable-verbose=true这一步踩了一些坑,这里说下解决方法:
- 找不到
cl.exe。
这是因为Visual Studio或者Build Tools for Visual Studio 2022的安装目录没有被加入系统目录。找到安装目录,然后导引到VC\Tools\MSVC\14.xxxx\bin\Hostx86\x86\,cl.exe就在这个目录里面,将其加入系统的Path环境变量。其中14.xxxx是版本号,Hostx86\x86\也可以是Hostx64\x64\,看想用32位编译器还是64位编译器。 - 找不到
MSVCRT.lib(或其他系统lib文件)。这里要检查第2步中activate的输出,一般是未能找到所需的MSVC编译器版本,这时第2步里面设置环境变量就会显示找不到vcvars64.bat。这里面需要注意pandas需要用VS2019的Build Toolset (v142),所以如果之前没有安装需要用Visual Studio Installer补上。

注意一定要用Desktop development with C++里面的MSVC v142 - VS2019 C++ x64/x86 build tools。原因是pandas给的conda脚本是根据VS的Component ID找VS安装目录的。只有这个Build tools符合脚本要求。如果安装的是Individual components里面的v142,那还是找不到,ID不一样。
- 找不到