0
点赞
收藏
分享

微信扫一扫

已经有了python3.7,还想安装python2.7怎么解决?

西特张 2022-01-10 阅读 178

之前是用anaconda安装的python3.7,项目需要python2.7,原环境都不想删。

打开anaconda prompt,输入命令:

(base) C:\Users\DELL>conda create --name python27 python=2.7
C:\Anaconda3\lib\site-packages\requests\__init__.py:91: RequestsDependencyWarning: urllib3 (1.26.7) or chardet (3.0.4) doesn't match a supported version!
  RequestsDependencyWarning)
Collecting package metadata (current_repodata.json): failed

UnavailableInvalidChannel: The channel is not accessible or is invalid.
  channel name: simple
  channel url: https://pypi.tuna.tsinghua.edu.cn/simple
  error code: 404

You will need to adjust your conda configuration to proceed.
Use `conda config --show channels` to view your configuration's current state,
and use `conda config --show-sources` to view config file locations.

报错了。

解决方法如下:

1、执行如下命令

(base) C:\Users\DELL>conda config --add channels r

2、在用户目录(C:\Users\DELL)下找到文件.condarc,打开,文件内容改为下面:

channels:
  - r
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

show_channel_urls: true
ssl_verify: true

3、再次执行安装py2.7命令,执行中输入两次Y,成功了。

查看版本:python --version

切换py27:activate python27

(base) C:\Users\DELL>conda create --name python27 python=2.7
C:\Anaconda3\lib\site-packages\requests\__init__.py:91: RequestsDependencyWarning: urllib3 (1.26.7) or chardet (3.0.4) doesn't match a supported version!
  RequestsDependencyWarning)
Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: C:\Anaconda3\envs\python27

  added / updated specs:
    - python=2.7


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    certifi-2016.2.28          |           py27_0         213 KB  http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
    pip-9.0.1                  |           py27_1         1.6 MB  http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
    python-2.7.13              |                1        23.8 MB  http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
    setuptools-36.4.0          |           py27_1         525 KB  http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
    vc-9                       |                0          705 B  http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
    vs2008_runtime-9.00.30729.5054|                0        1016 KB  http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
    wheel-0.29.0               |           py27_0         121 KB  http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
    wincertstore-0.2           |           py27_0          14 KB  http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
    ------------------------------------------------------------
                                           Total:        27.3 MB

The following NEW packages will be INSTALLED:

  certifi            anaconda/pkgs/free/win-64::certifi-2016.2.28-py27_0
  pip                anaconda/pkgs/free/win-64::pip-9.0.1-py27_1
  python             anaconda/pkgs/free/win-64::python-2.7.13-1
  setuptools         anaconda/pkgs/free/win-64::setuptools-36.4.0-py27_1
  vc                 anaconda/pkgs/free/win-64::vc-9-0
  vs2008_runtime     anaconda/pkgs/free/win-64::vs2008_runtime-9.00.30729.5054-0
  wheel              anaconda/pkgs/free/win-64::wheel-0.29.0-py27_0
  wincertstore       anaconda/pkgs/free/win-64::wincertstore-0.2-py27_0


Proceed ([y]/n)? y


Downloading and Extracting Packages
vc-9                 | 705 B     | ############################################################################ | 100%
pip-9.0.1            | 1.6 MB    | ############################################################################ | 100%
python-2.7.13        | 23.8 MB   | ############################################################################ | 100%
wincertstore-0.2     | 14 KB     | ############################################################################ | 100%
certifi-2016.2.28    | 213 KB    | ############################################################################ | 100%
wheel-0.29.0         | 121 KB    | ############################################################################ | 100%
setuptools-36.4.0    | 525 KB    | ############################################################################ | 100%
vs2008_runtime-9.00. | 1016 KB   | ############################################################################ | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
#     $ conda activate python27
#
# To deactivate an active environment, use
#
#     $ conda deactivate


(base) C:\Users\DELL>conda info --envs
C:\Anaconda3\lib\site-packages\requests\__init__.py:91: RequestsDependencyWarning: urllib3 (1.26.7) or chardet (3.0.4) doesn't match a supported version!
  RequestsDependencyWarning)
# conda environments:
#
base                  *  C:\Anaconda3
python27                 C:\Anaconda3\envs\python27


(base) C:\Users\DELL>python --version
Python 3.7.6

(base) C:\Users\DELL>activate python27

(python27) C:\Users\DELL>python --version
Python 2.7.13 :: Continuum Analytics, Inc.

(python27) C:\Users\DELL>
举报

相关推荐

0 条评论