Windows环境下Jupyter中skmultilearn模块导入失败求助
ModuleNotFoundError: No module named 'skmultilearn' in Jupyter (Windows) Let’s tackle your issues one by one, starting with the core module not found error since that’s blocking your code execution:
1. Resolve the skmultilearn module issue
The root problem here is almost certainly a mismatch between the Python environment you used to install skmultilearn and the one your Jupyter notebook is running. Here’s how to fix it:
Step 1: Find Jupyter’s active Python path
Open your Jupyter notebook and run this code in a cell:
import sys print(sys.executable)
This will output the full path to the Python executable your Jupyter kernel is using (e.g., C:\Users\YourName\anaconda3\python.exe or C:\Users\YourName\AppData\Local\Programs\Python\Python311\python.exe).
Step 2: Install skmultilearn to Jupyter’s environment
Open Command Prompt (CMD) on Windows, then run this command—replace <jupyter-python-path> with the path you copied from Step 1:
"<jupyter-python-path>" -m pip install scikit-multilearn
(Note: The official PyPI package name is scikit-multilearn, even though you import it as skmultilearn in your code.)
Step 3: For virtual environment users (optional but recommended)
If you’re using a virtual environment, make sure Jupyter recognizes it:
- Activate your virtual environment in CMD (e.g.,
venv\Scripts\activatefor a standard venv) - Install the ipykernel package to link the environment to Jupyter:
pip install ipykernel - Register the environment as a Jupyter kernel:
python -m ipykernel install --user --name=your-env-name --display-name="Python (your-env-name)" - Restart Jupyter, then switch to this new kernel via the
Kernel > Change kernelmenu before running your code.
2. Troubleshoot the stuck git clone
For the git clone issue in your Jupyter directory:
- First confirm Jupyter’s working directory by running this in a notebook cell:
import os print(os.getcwd()) - Open CMD, navigate to that directory with
cd "<jupyter-working-directory>", then run yourgit clone <repository-url>command directly here. - If it still fails, check:
- Your internet connection (can you access the git repository in a browser?)
- Directory permissions (try running CMD as Administrator if you get access denied errors)
- Git is properly installed (run
git --versionin CMD to verify)
Your original error for reference:
in ()
5 return_indicator = 'sparse', allow_unlabeled = False)
6 ----> 7 from skmultilearn.adapt import MLkNN
8
9 classifier = MLkNN(k=20)
ModuleNotFoundError: No module named 'skmultilearn'
内容的提问来源于stack exchange,提问作者capncook

