我正在Mac上的jupyter笔记本中浏览此网页的教程:。在练习结束时,我需要安装CATTOPY包。但是,我发现错误:
ModuleNotFoundError: No module named 'cartopy'
我尝试通过写作直接安装它:
!pip install cartopy
但是出现相同的错误。阅读stackoverflow和github上的几页,表明与虚拟环境有冲突,并且不能与PIP一起安装,但必须是conda。
我对Python很满意,但是虚拟环境和PIP与Conda的概念对我来说是完全陌生的。有人可以帮助我解决这个问题,但也解释了为什么我不能只是在安装此软件包?
谢谢你!
I am working through the tutorial on this webpage here in a Jupyter notebook on a Mac: https://towardsdatascience.com/kriging-the-french-temperatures-f0389ca908dd. Near the end of the exercise, I need to install the cartopy package. However, I get the error:
ModuleNotFoundError: No module named 'cartopy'
I've tried to directly install it by writing:
!pip install cartopy
but the same error appears. Reading through a few pages on Stackoverflow and Github suggest there is a conflict with the virtual environments and that this can not be installed with pip, but it has to be conda.
I'm fairly comfortable with Python, but the concept of virtual environments and pip vs. conda is completely foreign to me. Could someone help me solve this problem, but also explain why I'm unable to just pip install this package?
Thank you!
发布评论
评论(1)
您需要使用和理解虚拟环境。 PIP和CONDA都是为此的工具。通常,将首选Conda,对于将安装诸如GDAL()。本质上,像Conda这样的环境经理可以帮助您在计算机上使用不同版本的软件包保留多个环境。
使用conda
对于特定情况,您需要:
conda env create -f emoveration.yml
(请参见此答案)conda激活mapmaker
conda是一种多功能工具。我建议阅读他们的文档并搜索有关使用CONDA进行环境管理的一些教程
You need to use and understand virtual environments. pip and conda are both tools for this. Generally conda is preferred for cartopy as is will install non-Python tools like GDAL (cartopy installation docs). Essentially, an environment manager like conda helps you keep multiple environments on your computer with differing versions of packages.
Read about environment management with conda here
For your specific case, you need to:
conda env create -f environment.yml
(See this SO answer)conda activate mapmaker
conda is a versatile tool. I recommend reading their docs and searching for some tutorials on using conda for environment management