没有名为' CATTOPY'的模块+概念

发布于 2025-01-30 08:38:28 字数 567 浏览 4 评论 0 原文

我正在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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

素染倾城色 2025-02-06 08:38:28

您需要使用和理解虚拟环境。 PIP和CONDA都是为此的工具。通常,将首选Conda,对于将安装诸如GDAL()。本质上,像Conda这样的环境经理可以帮助您在计算机上使用不同版本的软件包保留多个环境。

使用conda

对于特定情况,您需要:

  1. 下载并安装Conda
  2. 制作一个环境文件,列出了所需的软件包。这将是一个称为emoverition.yml
name: mapmaker # or whatever you want to to call it 
channels:
  - conda-forge # this is the repo that contains cartopy, among other tools
dependencies:
        - ipython # for jupyter notebooks
        - numpy
        - pandas
        - cartopy # you can keep adding more packages here
  1. 使用此文件创建环境的明文文件(仅需要一次)

conda env create -f emoveration.yml 请参见此答案

  1. 激活环境(您每次需要时都可以这样做)

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:

  1. Download and install conda
  2. Make an environment file listing the packages you need. This will be a plaintext file called environment.yml
name: mapmaker # or whatever you want to to call it 
channels:
  - conda-forge # this is the repo that contains cartopy, among other tools
dependencies:
        - ipython # for jupyter notebooks
        - numpy
        - pandas
        - cartopy # you can keep adding more packages here
  1. Create an environment using this file (only need to do this once)

conda env create -f environment.yml (See this SO answer)

  1. Activate the environment (you do this every time you need it)

conda activate mapmaker

conda is a versatile tool. I recommend reading their docs and searching for some tutorials on using conda for environment management

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文