今天在pycharm上安装TensorFlow的时候出现了一些问题,记录在这里做一个备忘录,也希望能帮助到有相同问题的朋友。
问题一:Python版本要求
首先是,TensorFlow的安装有一些要求,这些要求可以访问官网(TensorFlow (google.cn))来查看:
为什么我要强调这个呢,可以看到,TensorFlow对Python的版本要求不仅有最老版本,还有最新版本。在我安装的时候,它只支持Python3.6-3.9,而隔壁的Python已经更新到Python3.12了。
这个问题的解决办法就是安装一个符合官网推荐版本的Python就好了。
问题二:pycharm无法连接到网络
安装好Python3.8之后,我尝试用pip命令来安装TensorFlow,但是报以下错误:
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError(0, 'Error'))': /s imple/upgrade/ WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError(0, 'Error'))': /s imple/upgrade/ WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError(0, 'Error'))': /s imple/upgrade/ WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError(0, 'Error'))': /s imple/upgrade/ WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connect to proxy.', OSError(0, 'Error'))': /s imple/upgrade/ ERROR: Could not find a version that satisfies the requirement upgrade (from versions: none) ERROR: No matching distribution found for upgrade
查了查,说是无法连接网络。试了很多方法,最终奏效的是:
关闭代理:在系统设置中找到代理设置,关闭“使用代理服务器”选项。
这样在pycharm中就可以正常连接到网络了。
pycharm代理设置
但是,这样设置以后只是治标不治本,当我们自己以后需要使用代理的时候,就不能够使用pycharm连接到网络了。
这个时候,我们就需要打开pycharm的代理设置,手动设置我们自己使用的代理:
这样,pycharm就同步了系统设置,以后就可以正常使用代理了。