使用Anaconda将Python 3.5升级至3.6时遇安装错误求助
Hey there! Let's work through this Python upgrade issue step by step—since you're new to Linux and Anaconda, I'll keep things clear and actionable. Here are the most common fixes for the error you're seeing when running conda install python==3.6:
1. First, Update Conda Itself
Old versions of Conda often struggle with handling newer Python versions or resolving dependencies correctly. Let's update the base Conda installation first to rule this out:
conda update -n base -c defaults conda
Once this finishes, try running your original upgrade command again: conda install python==3.6
2. Check for Dependency Conflicts
Sometimes existing packages in your environment are incompatible with Python 3.6, which blocks the upgrade. To identify exactly what's causing the conflict without making changes:
conda install python=3.6 --dry-run
This will show you a list of packages that can't coexist with Python 3.6. You have two options here:
- Uninstall the conflicting packages first (use
conda remove <package-name>), then retry the upgrade - Use the force-reinstall flag to overwrite conflicting packages (note: this can break your environment, so back up first!):
conda install python=3.6 --force-reinstall
3. (Recommended for Beginners) Create a New Python 3.6 Environment
Instead of upgrading your existing environment (which risks breaking existing projects), Anaconda is built for isolated environments—this is the safest approach for new users:
- Create a new environment with Python 3.6:
conda create -n py36env python=3.6 - Activate the new environment whenever you need to use Python 3.6:
conda activate py36env
Your original Python 3.5 environment will stay completely intact, so you can switch between them as needed for different projects.
4. Fix Conda Channel/Source Issues
If you're using non-default Conda channels (like some domestic mirrors), they might have outdated packages or sync problems. Try resetting to reliable default channels:
conda config --remove-key channels conda config --add channels defaults conda config --add channels conda-forge
Then run the upgrade command again.
Quick Tips
- If you're upgrading the
baseenvironment, make sure no other programs (like IDEs or open terminals) are using Python at the same time—this can cause file lock errors. - Always back up your environment before major changes! Export your current setup with
conda env export > environment.ymlto restore it later if something goes wrong.
内容的提问来源于stack exchange,提问作者Patthebug




