如何在 Windows PC 上安装 pygalmesh(取决于 Eigen)?
How does one install pygalmesh (which depends on Eigen) on a Windows PC?
编辑:对于那些感兴趣的人,创作者目前正在努力here。
我正在尝试安装 pygalmesh using pip install pygalmesh
, which depends on Eigen。我已经下载了 Eigen,但是 pip 安装程序没有 "know" 这个。它 returns 以下错误消息:
ERROR: Could not build wheels for pygalmesh which use PEP 517 and cannot be installed directly
更具体地说:
fatal error C1083: Cannot open include file: 'Eigen/Dense':
Pygalmesh 的 github has a file for setup.py 我可以编辑,但我不知道我将如何安装 pygalmesh。还在使用 pip?
是否有我可以编辑的 setup.py 文件,以便安装程序知道 Eigen/Dense 的位置?由于我有一台 Windows PC,我认为至少 /
需要更改为 \
。但是我找不到要编辑的setup.py。
我在 web, also here. I don't know how to implement what is talked about in these posts. I have also tried installing eigen through conda, like here 的其他地方找到了关于这个问题的对话。这也没有用。
完整的错误消息:
Collecting pygalmesh
Using cached pygalmesh-0.6.2.tar.gz (1.2 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Installing backend dependencies ... done
Preparing wheel metadata ... done
Collecting pybind11>=2.2
Using cached pybind11-2.5.0.tar.gz (139 kB)
Collecting meshio<5.0.0,>=4.0.0
Downloading meshio-4.0.11.tar.gz (302 kB)
|████████████████████████████████| 302 kB 2.2 MB/s
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... done
Requirement already satisfied: importlib-metadata in c:\users\user\anaconda3\lib\site-packages (from pygalmesh) (1.5.0)
Requirement already satisfied: numpy in c:\users\user\anaconda3\lib\site-packages (from pygalmesh) (1.16.2)
Requirement already satisfied: zipp>=0.5 in c:\users\user\anaconda3\lib\site-packages (from importlib-metadata->pygalmesh) (2.2.0)
Skipping wheel build for pybind11, due to binaries being disabled for it.
Building wheels for collected packages: pygalmesh, meshio
Building wheel for pygalmesh (PEP 517) ... error
ERROR: Command errored out with exit status 1:
command: 'C:\Users\User\Anaconda3\python.exe' 'C:\Users\User\Anaconda3\lib\site-packages\pip\_vendor\pep517\_in_process.py' build_wheel 'C:\Users\User\AppData\Local\Temp\tmpa0eqknmo'
cwd: C:\Users\User\AppData\Local\Temp\pip-install-qm6jy0mx\pygalmesh
Complete output (24 lines):
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win-amd64-3.7
creating build\lib.win-amd64-3.7\pygalmesh
copying pygalmesh\main.py -> build\lib.win-amd64-3.7\pygalmesh
copying pygalmesh\__about__.py -> build\lib.win-amd64-3.7\pygalmesh
copying pygalmesh\__init__.py -> build\lib.win-amd64-3.7\pygalmesh
creating build\lib.win-amd64-3.7\pygalmesh\_cli
copying pygalmesh\_cli\helpers.py -> build\lib.win-amd64-3.7\pygalmesh\_cli
copying pygalmesh\_cli\_inr.py -> build\lib.win-amd64-3.7\pygalmesh\_cli
copying pygalmesh\_cli\_remesh_surface.py -> build\lib.win-amd64-3.7\pygalmesh\_cli
copying pygalmesh\_cli\_volume_from_surface.py -> build\lib.win-amd64-3.7\pygalmesh\_cli
copying pygalmesh\_cli\__init__.py -> build\lib.win-amd64-3.7\pygalmesh\_cli
running build_ext
building '_pygalmesh' extension
creating build\temp.win-amd64-3.7
creating build\temp.win-amd64-3.7\Release
creating build\temp.win-amd64-3.7\Release\src
C:\Program Files (x86)\Microsoft Visual Studio19\Community\VC\Tools\MSVC.22.27905\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -I/usr/include/eigen3/ -IC:\Users\User\AppData\Local\Temp\pip-build-env-bi2kt8ry\normal\Lib\site-packages\pybind11\include -IC:\Users\User\AppData\Local\Temp\pip-build-env-bi2kt8ry\normal\Lib\site-packages\pybind11\include -IC:\Users\User\Anaconda3\include -IC:\Users\User\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio19\Community\VC\Tools\MSVC.22.27905\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio19\Community\VC\Tools\MSVC.22.27905\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK.7.2\include\um" "-IC:\Program Files (x86)\Windows Kits\include.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\include.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\include.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\include.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\include.0.18362.0\cppwinrt" /EHsc /Tpsrc/generate.cpp /Fobuild\temp.win-amd64-3.7\Release\src/generate.obj
generate.cpp
C:\Users\User\AppData\Local\Temp\pip-install-qm6jy0mx\pygalmesh\src\domain.hpp(4): fatal error C1083: Cannot open include file: 'Eigen/Dense': No such file or directory
error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\bin\HostX86\x64\cl.exe' failed with exit status 2
----------------------------------------
ERROR: Failed building wheel for pygalmesh
Building wheel for meshio (PEP 517) ... done
Created wheel for meshio: filename=meshio-4.0.11-py3-none-any.whl size=127526 sha256=cc63c5792c3d20bce3532742afcccc100bc6312c1254e029f8771f286a5979c2
Stored in directory: c:\users\user\appdata\local\pip\cache\wheels\cf\b034bc0b8bffd85475dfbab9791fcdeea89c77f040c4537afe
Successfully built meshio
Failed to build pygalmesh
ERROR: Could not build wheels for pygalmesh which use PEP 517 and cannot be installed directly
在 pygalmesh
github, the community and creator solved the problem. See here 上提出问题后。只需:
conda install -c conda-forge pygalmesh
此解决方案适用于 Windows 10,安装了 python 3.8 和 Visual Studio Community 2019。
安装依赖项:gmp
、mpfr
、eigen3
和 cgal
。我建议 vcpkg
用于库构建和安装,如下所述。您也可以按照自己的方式单独安装和构建这些依赖项,而无需 vcpkg
.
1.1。安装 vcpkg
(https://vcpkg.io/en/getting-started.html).
1.2。在 x64 静态配置上安装依赖项:
vcpkg install gmp:x64-windows-static
vcpkg install mpfr:x64-windows-static
vcpkg install eigen3:x64-windows-static
vcpkg install cgal:x64-windows-static
克隆 pygalmesh
来源:
git clone https://github.com/nschloe/pygalmesh.git
将library_dirs=["C:/path/to/vcpkg/installed/x64-windows-static/lib"]
添加到pygalmesh/setup.py
(参见Modified setup.py below the post,同时勾选备选方案)。 不要忘记插入您自己的 vcpkg
位置而不是我的 /path/to/vcpkg
.
构建并安装pygalmesh
:
cd pygalmesh
set EIGEN_INCLUDE_DIR=C:/path/to/vcpkg/installed/x64-windows-static/include
pip install .
确保 pygalmesh
已安装:
python
>>> import pygalmesh
已修改setup.py
import os
from pybind11.setup_helpers import Pybind11Extension, build_ext
from setuptools import setup
# https://github.com/pybind/python_example/
ext_modules = [
Pybind11Extension(
"_pygalmesh",
# Sort input source files to ensure bit-for-bit reproducible builds
# (https://github.com/pybind/python_example/pull/53)
sorted(
[
"src/generate.cpp",
"src/generate_2d.cpp",
"src/generate_from_inr.cpp",
"src/generate_from_off.cpp",
"src/generate_periodic.cpp",
"src/generate_surface_mesh.cpp",
"src/remesh_surface.cpp",
"src/pybind11.cpp",
]
),
include_dirs=[os.environ.get("EIGEN_INCLUDE_DIR", "/usr/include/eigen3/")],
# no CGAL libraries necessary from CGAL 5.0 onwards
libraries=["gmp", "mpfr"],
# !!! ADD YOUR PATH HERE !!!
library_dirs=["C:/D/Apps/vcpkg/installed/x64-windows-static/lib"]
)
]
if __name__ == "__main__":
setup(
cmdclass={"build_ext": build_ext},
ext_modules=ext_modules,
zip_safe=False,
)
备选方案
事实上,pip
具有指向库路径的命令行参数(--global-option=build_ext
、--include-path
、--library-path
see pip docs and this post),以及一个潜在的安装可以是一对行(在安装 C++ 库的第 1 步之后):
set EIGEN_INCLUDE_DIR=C:/path/to/vcpkg/installed/x64-windows-static/include
pip install --global-option=build_ext --install-option="--include-path=C:\path\to\vcpkg\installed\x64-windows-static\include" --global-option="--library-path=C:\path\to\vcpkg\installed\x64-windows-static\lib" pygalmesh
但是。由于某种原因(可能只是我的系统配置功能,或 setuptools==58.1.0
版本特定的“功能”) setuptools
不要将 --library-path
参数放入 MSVC 的 /LIBPATH:
键link.exe
构建包时,导致LNK错误。
编辑:对于那些感兴趣的人,创作者目前正在努力here。
我正在尝试安装 pygalmesh using pip install pygalmesh
, which depends on Eigen。我已经下载了 Eigen,但是 pip 安装程序没有 "know" 这个。它 returns 以下错误消息:
ERROR: Could not build wheels for pygalmesh which use PEP 517 and cannot be installed directly
更具体地说:
fatal error C1083: Cannot open include file: 'Eigen/Dense':
Pygalmesh 的 github has a file for setup.py 我可以编辑,但我不知道我将如何安装 pygalmesh。还在使用 pip?
是否有我可以编辑的 setup.py 文件,以便安装程序知道 Eigen/Dense 的位置?由于我有一台 Windows PC,我认为至少 /
需要更改为 \
。但是我找不到要编辑的setup.py。
我在 web, also here. I don't know how to implement what is talked about in these posts. I have also tried installing eigen through conda, like here 的其他地方找到了关于这个问题的对话。这也没有用。
完整的错误消息:
Collecting pygalmesh
Using cached pygalmesh-0.6.2.tar.gz (1.2 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Installing backend dependencies ... done
Preparing wheel metadata ... done
Collecting pybind11>=2.2
Using cached pybind11-2.5.0.tar.gz (139 kB)
Collecting meshio<5.0.0,>=4.0.0
Downloading meshio-4.0.11.tar.gz (302 kB)
|████████████████████████████████| 302 kB 2.2 MB/s
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... done
Requirement already satisfied: importlib-metadata in c:\users\user\anaconda3\lib\site-packages (from pygalmesh) (1.5.0)
Requirement already satisfied: numpy in c:\users\user\anaconda3\lib\site-packages (from pygalmesh) (1.16.2)
Requirement already satisfied: zipp>=0.5 in c:\users\user\anaconda3\lib\site-packages (from importlib-metadata->pygalmesh) (2.2.0)
Skipping wheel build for pybind11, due to binaries being disabled for it.
Building wheels for collected packages: pygalmesh, meshio
Building wheel for pygalmesh (PEP 517) ... error
ERROR: Command errored out with exit status 1:
command: 'C:\Users\User\Anaconda3\python.exe' 'C:\Users\User\Anaconda3\lib\site-packages\pip\_vendor\pep517\_in_process.py' build_wheel 'C:\Users\User\AppData\Local\Temp\tmpa0eqknmo'
cwd: C:\Users\User\AppData\Local\Temp\pip-install-qm6jy0mx\pygalmesh
Complete output (24 lines):
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win-amd64-3.7
creating build\lib.win-amd64-3.7\pygalmesh
copying pygalmesh\main.py -> build\lib.win-amd64-3.7\pygalmesh
copying pygalmesh\__about__.py -> build\lib.win-amd64-3.7\pygalmesh
copying pygalmesh\__init__.py -> build\lib.win-amd64-3.7\pygalmesh
creating build\lib.win-amd64-3.7\pygalmesh\_cli
copying pygalmesh\_cli\helpers.py -> build\lib.win-amd64-3.7\pygalmesh\_cli
copying pygalmesh\_cli\_inr.py -> build\lib.win-amd64-3.7\pygalmesh\_cli
copying pygalmesh\_cli\_remesh_surface.py -> build\lib.win-amd64-3.7\pygalmesh\_cli
copying pygalmesh\_cli\_volume_from_surface.py -> build\lib.win-amd64-3.7\pygalmesh\_cli
copying pygalmesh\_cli\__init__.py -> build\lib.win-amd64-3.7\pygalmesh\_cli
running build_ext
building '_pygalmesh' extension
creating build\temp.win-amd64-3.7
creating build\temp.win-amd64-3.7\Release
creating build\temp.win-amd64-3.7\Release\src
C:\Program Files (x86)\Microsoft Visual Studio19\Community\VC\Tools\MSVC.22.27905\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -I/usr/include/eigen3/ -IC:\Users\User\AppData\Local\Temp\pip-build-env-bi2kt8ry\normal\Lib\site-packages\pybind11\include -IC:\Users\User\AppData\Local\Temp\pip-build-env-bi2kt8ry\normal\Lib\site-packages\pybind11\include -IC:\Users\User\Anaconda3\include -IC:\Users\User\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio19\Community\VC\Tools\MSVC.22.27905\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio19\Community\VC\Tools\MSVC.22.27905\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK.7.2\include\um" "-IC:\Program Files (x86)\Windows Kits\include.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\include.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\include.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\include.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\include.0.18362.0\cppwinrt" /EHsc /Tpsrc/generate.cpp /Fobuild\temp.win-amd64-3.7\Release\src/generate.obj
generate.cpp
C:\Users\User\AppData\Local\Temp\pip-install-qm6jy0mx\pygalmesh\src\domain.hpp(4): fatal error C1083: Cannot open include file: 'Eigen/Dense': No such file or directory
error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\bin\HostX86\x64\cl.exe' failed with exit status 2
----------------------------------------
ERROR: Failed building wheel for pygalmesh
Building wheel for meshio (PEP 517) ... done
Created wheel for meshio: filename=meshio-4.0.11-py3-none-any.whl size=127526 sha256=cc63c5792c3d20bce3532742afcccc100bc6312c1254e029f8771f286a5979c2
Stored in directory: c:\users\user\appdata\local\pip\cache\wheels\cf\b034bc0b8bffd85475dfbab9791fcdeea89c77f040c4537afe
Successfully built meshio
Failed to build pygalmesh
ERROR: Could not build wheels for pygalmesh which use PEP 517 and cannot be installed directly
在 pygalmesh
github, the community and creator solved the problem. See here 上提出问题后。只需:
conda install -c conda-forge pygalmesh
此解决方案适用于 Windows 10,安装了 python 3.8 和 Visual Studio Community 2019。
安装依赖项:
gmp
、mpfr
、eigen3
和cgal
。我建议vcpkg
用于库构建和安装,如下所述。您也可以按照自己的方式单独安装和构建这些依赖项,而无需vcpkg
.1.1。安装
vcpkg
(https://vcpkg.io/en/getting-started.html).1.2。在 x64 静态配置上安装依赖项:
vcpkg install gmp:x64-windows-static vcpkg install mpfr:x64-windows-static vcpkg install eigen3:x64-windows-static vcpkg install cgal:x64-windows-static
克隆
pygalmesh
来源:git clone https://github.com/nschloe/pygalmesh.git
将
library_dirs=["C:/path/to/vcpkg/installed/x64-windows-static/lib"]
添加到pygalmesh/setup.py
(参见Modified setup.py below the post,同时勾选备选方案)。 不要忘记插入您自己的vcpkg
位置而不是我的/path/to/vcpkg
.构建并安装
pygalmesh
:cd pygalmesh set EIGEN_INCLUDE_DIR=C:/path/to/vcpkg/installed/x64-windows-static/include pip install .
确保
pygalmesh
已安装:python >>> import pygalmesh
已修改setup.py
import os
from pybind11.setup_helpers import Pybind11Extension, build_ext
from setuptools import setup
# https://github.com/pybind/python_example/
ext_modules = [
Pybind11Extension(
"_pygalmesh",
# Sort input source files to ensure bit-for-bit reproducible builds
# (https://github.com/pybind/python_example/pull/53)
sorted(
[
"src/generate.cpp",
"src/generate_2d.cpp",
"src/generate_from_inr.cpp",
"src/generate_from_off.cpp",
"src/generate_periodic.cpp",
"src/generate_surface_mesh.cpp",
"src/remesh_surface.cpp",
"src/pybind11.cpp",
]
),
include_dirs=[os.environ.get("EIGEN_INCLUDE_DIR", "/usr/include/eigen3/")],
# no CGAL libraries necessary from CGAL 5.0 onwards
libraries=["gmp", "mpfr"],
# !!! ADD YOUR PATH HERE !!!
library_dirs=["C:/D/Apps/vcpkg/installed/x64-windows-static/lib"]
)
]
if __name__ == "__main__":
setup(
cmdclass={"build_ext": build_ext},
ext_modules=ext_modules,
zip_safe=False,
)
备选方案
事实上,pip
具有指向库路径的命令行参数(--global-option=build_ext
、--include-path
、--library-path
see pip docs and this post),以及一个潜在的安装可以是一对行(在安装 C++ 库的第 1 步之后):
set EIGEN_INCLUDE_DIR=C:/path/to/vcpkg/installed/x64-windows-static/include
pip install --global-option=build_ext --install-option="--include-path=C:\path\to\vcpkg\installed\x64-windows-static\include" --global-option="--library-path=C:\path\to\vcpkg\installed\x64-windows-static\lib" pygalmesh
但是。由于某种原因(可能只是我的系统配置功能,或 setuptools==58.1.0
版本特定的“功能”) setuptools
不要将 --library-path
参数放入 MSVC 的 /LIBPATH:
键link.exe
构建包时,导致LNK错误。