安装Jupyter Hub后Conda失效,如何恢复至Python3.6环境?
Alright, let's work through this step by step. The root problem is that installing JupyterHub from conda-forge pulled in Python 3.7, which overwrote your default Python path—making conda look for its modules in the wrong (3.7) environment instead of your working Python 3.6 setup. Here's how to get everything back on track:
1. Temporarily Restore Conda Access
First, we'll use your working Python 3.6 executable to run conda directly, bypassing the broken default path.
Find your Python 3.6 executable path (you mentioned it exists in your conda install directory—let's assume it's /data/pyconda3/python3.6/bin/python). Run this command to test if conda works with it:
/data/pyconda3/python3.6/bin/python /data/pyconda3/bin/conda --version
If this returns a valid conda version, we're good to move forward.
2. Activate Your Original Python 3.6 Environment
Use the same Python 3.6 path to activate your base (or preferred) 3.6 environment:
source /data/pyconda3/python3.6/bin/activate base
Once activated, you should be able to run conda directly without the full path now—test it with conda --version to confirm.
3. Reinstall Conda to Bind It to Python 3.6
To fix the broken module link, force-reinstall conda in your 3.6 environment:
conda install -n base conda --force-reinstall
This will refresh the conda modules and ensure they're tied to your Python 3.6 installation.
4. Set Python 3.6 as Your Default
Now we need to make sure your shell uses Python 3.6 by default:
- Check your current default Python path with
which python. If it points to Python 3.7, update yourPATHenvironment variable to prioritize the 3.6 bin directory:export PATH="/data/pyconda3/python3.6/bin:$PATH" - To make this permanent, add the above line to your shell config file (e.g.,
~/.bashrcor~/.zshrc), then reload it:source ~/.bashrc - Fix any broken symlinks in your conda bin directory. If
/data/pyconda3/bin/pythonlinks to Python 3.7, re-point it to 3.6:ln -sf /data/pyconda3/python3.6/bin/python /data/pyconda3/bin/python ln -sf /data/pyconda3/python3.6/bin/python3 /data/pyconda3/bin/python3
5. Uninstall Python 3.7
Since Python 3.7 was installed via conda, we can safely remove it using your restored conda setup:
- First, list all conda environments to check if 3.7 is in a separate environment:
conda env list - If it's in a dedicated environment, delete that environment with:
conda env remove -n <environment-name> - If 3.7 was installed in your base environment (unlikely, but possible), remove it directly:
conda remove python=3.7 --all
6. Verify Everything Works
Run these commands to confirm your setup is back to normal:
conda --version # Should show your conda version without errors python --version # Should return Python 3.6.x jupyter lab # Should launch as it did before
If you still need JupyterHub, install it again but explicitly specify Python 3.6 to avoid pulling in 3.7:
conda install -c conda-forge jupyterhub python=3.6
内容的提问来源于stack exchange,提问作者RevivedPicard

