Ubuntu16.04下Python2.7安装Jupyter Notebook时scandir报错(错误码1)
I’ve run into this exact issue before on Ubuntu 16.04 with Python 2.7—scandir’s C extension fails to build because of missing system dependencies or incompatible package versions. Here are the practical fixes that worked for me:
1. Install Required Build Dependencies
Scandir is a C-based library, so it needs GCC and Python development headers to compile successfully. Run these commands first to get the necessary tools:
sudo apt-get update sudo apt-get install build-essential python-dev
Once installed, try re-running the Jupyter installation command:
pip install jupyter
2. Pin Scandir to a Python 2.7-Compatible Version
Newer versions of scandir dropped support for Python 2.7 entirely. Install an older, compatible version explicitly before installing Jupyter:
pip install scandir==1.10.0
Then proceed with the Jupyter install:
pip install jupyter
3. Upgrade Pip to the Last Python 2.7-Supported Version
Outdated pip versions often struggle with resolving dependencies for legacy Python releases. Upgrade pip to the final version that supports Python 2.7 first:
pip install --upgrade pip==20.3.4
After upgrading, retry installing Jupyter.
Bonus: Use a Virtual Environment (Recommended)
To avoid messing with system-wide Python packages, create an isolated virtual environment for your Jupyter setup:
sudo apt-get install python-virtualenv virtualenv jupyter_env source jupyter_env/bin/activate
Run all the above installation steps inside this activated environment to keep your system clean.
内容的提问来源于stack exchange,提问作者ninghang.mei

