在Anaconda Spyder中运行Python代码出现simplekml模块缺失错误求助
Fixing
ModuleNotFoundError: No module named 'simplekml' in Spyder (Anaconda Python 3.6) Hey there! Let's break down why you're hitting this error and how to fix it quickly.
Why this error happens
The simplekml module isn't part of Python's standard library, and it's not pre-installed with Anaconda by default. Your Spyder environment (Python 3.6) just doesn't have the package installed yet—so Python can't find it when you try to import it.
How to install simplekml in your Anaconda environment
You have two easy ways to get this package set up:
Method 1: Use Anaconda Navigator (GUI)
- Open Anaconda Navigator from your start menu (Windows) or applications folder (Mac/Linux)
- Switch to the Environments tab (top navigation bar)
- Select your Python 3.6 environment from the list on the left (it might be named
baseor a custom name you created) - In the search box at the top, type
simplekml—the package should show up in the list below - Check the box next to
simplekml, then click the Apply button in the bottom right to start the installation
Method 2: Use the command line (Anaconda Prompt/Terminal)
If you prefer using the command line:
- Open Anaconda Prompt (Windows) or your system's terminal (Mac/Linux)
- Activate your Python 3.6 environment first:
Replaceconda activate your-environment-nameyour-environment-namewith the actual name of your environment (e.g.,baseif you're using the default Anaconda environment) - Install
simplekmlusing eitherconda(recommended for Anaconda environments) orpip:- Using conda (from the conda-forge channel, since it's not in the default conda repo):
conda install -c conda-forge simplekml - If conda doesn't find the package, use pip instead:
pip install simplekml
- Using conda (from the conda-forge channel, since it's not in the default conda repo):
Important post-install step
After installing the package, restart Spyder. Sometimes Spyder doesn't pick up newly installed packages until you close and reopen it.
Once you've done that, run your code again—it should no longer throw the ModuleNotFoundError!
内容的提问来源于stack exchange,提问作者user9630712
相关产品推荐
相关产品推荐

