1.配置环境变量。一定要勾选 Add Anaconda to my PATH environment variable,将 Anaconda 添加到环境变量。
2.将 Anaconda 设为默认的 Python 环境。勾选 Register Anaconda as my default Python 3.7。
如下命令说明安装成功
1 2
C:\Users\HASEE>conda --version conda 4.7.12
下面来配置,让两个版本的python和pip可以共存在windows上。
进入python2.7的目录
将python.exe改为python2.exe
然后运行命令
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
C:\Users\HASEE>python2 -m pip install --upgrade pip --force-reinstall DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support Collecting pip Using cached https://files.pythonhosted.org/packages/00/b6/9cfa56b4081ad13874b0c6f96af8ce16cfbc1cb06bedf8e9164ce5551ec1/pip-19.3.1-py2.py3-none-any.whl Installing collected packages: pip Found existing installation: pip 19.3.1 Uninstalling pip-19.3.1: Successfully uninstalled pip-19.3.1 Successfully installed pip-19.3.1 C:\Users\HASEE>python -m pip install --upgrade pip --force-reinstall Collecting pip Using cached https://files.pythonhosted.org/packages/00/b6/9cfa56b4081ad13874b0c6f96af8ce16cfbc1cb06bedf8e9164ce5551ec1/pip-19.3.1-py2.py3-none-any.whl Installing collected packages: pip Found existing installation: pip 19.3.1 Uninstalling pip-19.3.1: Successfully uninstalled pip-19.3.1 Successfully installed pip-19.3.1
C:\Users\HASEE>pip2 --version pip 19.3.1 from d:\python27\lib\site-packages\pip (python 2.7)
C:\Users\HASEE>pip3 --version pip 19.3.1 from d:\anaconda3\lib\site-packages\pip (python 3.7)
C:\Users\HASEE>python2 Python 2.7.16 (v2.7.16:413a49145e, Mar 4 2019, 01:37:19) [MSC v.1500 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license"for more information. >>>
C:\Users\HASEE>python Python 3.7.4 (default, Aug 9 2019, 18:34:13) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Warning: This Python interpreter is in a conda environment, but the environment has not been activated. Libraries may fail to load. To activate this environment please see https://conda.io/activation
Type "help", "copyright", "credits" or "license"for more information. >>>
测试成功,两个版本的python成功共存。
使用此种方法配置,不但可以共存还可以使用conda在虚拟环境中配置python
如果报以下错误:
1 2
C:\Users\HASEE>virtualenv Fatal error in launcher: Unable to create process using '"d:\python27\python.exe" "D:\Python27\Scripts\virtualenv.exe"