在Pycharm中更新安装最新版本pip,安装tensorflow

在pycharm中安装tensorflow时,安装失败,并且终端显示:

WARNING: You are using pip version 20.1.1; however, version 22.3 is available.
You should consider upgrading via the 'D:\PythonStudy\venv\Scripts\python.exe -m pip instal
l --upgrade pip' command.

此时选择安装,最新版的pip,在终端中输入:

python -m pip install --upgrade pip -i https://pypi.douban.com/simple

但是此时报错:
出现:UnicodeDecodeError: ‘gbk’ codec can’t decode byte 0xa3 in position 20:illegal multibyte sequence
在Pycharm中更新安装最新版本pip,安装tensorflow_第1张图片
此时可以转至该文件这部分
比如我的:

    try:
        # Although PEP 405 does not specify, the built-in venv module always
        # writes with UTF-8. (pypa/pip#8717)
        with open(pyvenv_cfg_file) as f:
            return f.read().splitlines()  # avoids trailing newlines
    except OSError:
        return None

将 with open 行改变如下:

with open(pyvenv_cfg_file, encoding="utf-8") as f:

然后再安装更新pip:

python -m pip install --upgrade pip -i https://pypi.douban.com/simple

更新pip就成功了
在Pycharm中更新安装最新版本pip,安装tensorflow_第2张图片
随后进行安装tensorflow,使用镜像安装更快:

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow

成功:
在Pycharm中更新安装最新版本pip,安装tensorflow_第3张图片


参考:https://blog.csdn.net/weixin_44852386/article/details/105477524

你可能感兴趣的:(python,tensorflow,pip,python)