我想在 Windows 上安装 Cartopy,根据 http://scitools.org.uk/cartopy/docs/latest/installing.html#installing,它有一些依赖项。 在 cmd 提示符下使用
pip install cartopy
时,它会在要我安装 GEOS 3.3.3 和 Proj4 4.9.0. 的地方给出错误
我已经下载了geos-3.6.2.tar.bz2,但我不知道如何安装它。我已经提取了文件,使用
cd
到正确的目录。
我该怎么做才能正确安装它? 有安装 Cartopy 的简单方法吗?
你有 Anaconda 吗?
尝试:
conda 安装-c scitools cartopy
当您通过 pip 安装时,最好使用二进制文件 .Whl 扩展文件进行安装 您可以在下面找到所有的包二进制文件。 特别是在通过 pip 安装 Cartopy 的情况下,使用二进制 wheel 文件安装 cartopy。
如果您在 Windows 上并且已经安装了 Anaconda,请在搜索中键入“Anaconda prompt”,然后键入此命令
conda install -c conda-forge cartopy
我试过了
conda install -c conda-forge cartopy
并尝试通过 Anaconda navigator 1.9.12 安装它,我搜索了多种方法并尝试了所有方法但都失败了。只有这个
conda install -c scitools cartopy
作品。
我首先按照此处响应中提供的说明运行此
conda update -n base -c defaults condo
:更新Anaconda失败:环境不可写错误
对于它的价值,我设法在 Windows 10 上使用 python 3.10.9 和 Cartopy==0.21.1 构建并安装了 cartopy(和 cartes):
global-options
东西here所有这一切的基础是自定义构建https://libgeos.org
你需要:
python -m venv venv
或者
py -3.10 -m venv venv
我不记得我安装了哪个版本...逆向分析表明,这是在
pip install cartopy
命令之后的某个时刻被调用或引用的:
MSBuild version 17.5.1+f6fdcf537 for .NET Framework
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\ and child dirs
C:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ and child dirs
安装巧克力
打开 Powershell 控制台“Developer PowerShell for VS 2022”并激活您的 venv
venv\Scripts\activate.ps1
chocolatey install cmake
我使用的是 3.11.2 版本,但是可以根据需要使用任何版本。 我选择安装成
%ProgramFiles%
,再说一遍,随便拿吧
cd the_unzip_dir
mkdir _build
cd _build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="%ProgramFiles%\geos-3.11.2" ..
Cmake 将检测 Visual Studio 工具套件并生成一堆 MSVS 项目文件 (
*.vcxproj
)。
(如果你尝试不使用 VS 但使用 minggw 会发生什么……我不知道。)
msbuild.exe .\ALL_BUILD.vcxproj
msbuild.exe .\INSTALL.vcxproj
%ProgramFiles%
在windows中翻译成C:\Program Files
(带空格))set GEOS_INCLUDE_PATH="C:\Program Files\geos-3.11.2\include"
set GEOS_LIBRARY_PATH="C:\Program Files\geos-3.11.2\bin"
set PATH="C:\Program Files\geos-3.11.2\lib";%GEOS_INCLUDE_PATH%;%GEOS_LIBRARY_PATH%;%PATH%
(这是用于 pip 安装阶段)
mkdir venv\libs
mkdir venv\include
xcopy /E "%ProgramFiles%\geos-3.11.2\bin" venv\libs
xcopy /E "%ProgramFiles%\geos-3.11.2\lib" venv\libs
xcopy /E "%ProgramFiles%\geos-3.11.2\include" venv\include
pip install cartopy
Building wheels for collected packages: cartopy
Building wheel for cartopy (pyproject.toml) ... done
Created wheel for cartopy: filename=Cartopy-0.21.1-cp311-cp311-win_amd64.whl size=10785690 sha256=88a2afb9224263f8269a99a2f71ecc503f105ec54166dcd9c446e3abc61477c1
Stored in directory: c:\users\<ME>\appdata\local\pip\cache\wheels\e0\34\c2\3c8ace93982cfef7b3b142d6b4f6ef30321b9768a80c115c70
Successfully built cartopy
💯
xcopy /E "%ProgramFiles%\geos-3.11.2\bin" venv\Lib\site-packages\cartopy
xcopy /E "%ProgramFiles%\geos-3.11.2\lib" venv\Lib\site-packages\cartopy
pip install cartes
python
Python 3.11.2 (tags/v3.11.2:878ead1, Feb 7 2023, 16:38:35) [MSC v.1934 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cartopy
>>> import cartopy.trace
>>> from cartes.crs import Lambert93
>>> dir(cartopy.trace)
['CartesianInterpolator', 'Geod', 'Interpolator', 'LineAccumulator', 'ProjError', 'SphericalInterpolator', 'Transformer', '_Testing', '__builtins__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__pyx_unpickle_LineAccumulator', '__spec__', '__test__', '_interpolator', 'lru_cache', 'project_linear', 're', 'sgeom', 'warnings']
>>> print(cartopy.trace.__doc__)
This module pulls together proj, GEOS and ``_crs.pyx`` to implement a function
to project a `~shapely.geometry.LinearRing` / `~shapely.geometry.LineString`.
In general, this should never be called manually, instead leaving the
processing to be done by the :class:`cartopy.crs.Projection` subclasses.
>>>print("Looks fine !")
导致点冻结:
pip freeze
aiohttp==3.8.4
aiosignal==1.3.1
altair==4.2.2
appdirs==1.4.4
async-timeout==4.0.2
attrs==23.1.0
beautifulsoup4==4.12.2
cartes==0.7.4
Cartopy==0.21.1
certifi==2022.12.7
charset-normalizer==3.1.0
click==8.1.3
click-plugins==1.1.1
cligj==0.7.2
colorama==0.4.6
contourpy==1.0.7
cycler==0.11.0
entrypoints==0.4
Fiona==1.9.3
fonttools==4.39.3
frozenlist==1.3.3
geopandas==0.12.2
idna==3.4
Jinja2==3.1.2
jsonschema==4.17.3
kiwisolver==1.4.4
lxml==4.9.2
markdown-it-py==2.2.0
MarkupSafe==2.1.2
matplotlib==3.7.1
mdurl==0.1.2
multidict==6.0.4
munch==2.5.0
numpy==1.24.2
packaging==23.1
pandas==2.0.0
Pillow==9.5.0
Pygments==2.15.1
pyparsing==3.0.9
pyproj==3.5.0
pyrsistent==0.19.3
pyshp==2.3.1
python-dateutil==2.8.2
pytz==2023.3
requests==2.28.2
rich==13.3.4
scipy==1.10.1
shapely==2.0.1
six==1.16.0
soupsieve==2.4.1
toolz==0.12.0
tqdm==4.65.0
tzdata==2023.3
urllib3==1.26.15
yarl==1.8.2