pycharm中导入模块错误时提示Try to run this command from the system terminal

脚本专栏 发布日期:2024/10/22 浏览次数:1

正在浏览:pycharm中导入模块错误时提示Try to run this command from the system terminal

pycharm中导入模块错误时,提示:Try to run this command from the system terminal. Make sure that you use the correct version of ‘pip' installed for your Python interpreter located atpycharm工作路径。

安装好pycharm,而且Python中安装了keras,在pycharm中导入keras时提示如题信息;上网查找资料,需要先添加keras库,步骤如下:pycharm菜单栏 File Settings…然后单击Project Project Interpreter 在里面Project Interpreter界面最右边有个加号,单击加号,然后在搜索框输入keras/tiffile/matplotlib,找到后单击左下方的Install Package即可。一般情况下这样是可以成功的,但是报错,提示信息大概意思是pip版本不对。原来默认下载地址(https://pypi.python.org/simple)。

发现通过这种方法导入的keras模块和自己之前安装的不是python中安装的,是重新安装的。比如我的电脑之前anaconda中安装的是2.1.1版本 ,而这种方法是安装的2.3.1版本的。是否pycharm工作路径和python工作路径不一样,则需要重新下载安装需要的模块?

pycharm中导入模块错误时提示Try to run this command from the system terminal
pycharm中导入模块错误时提示Try to run this command from the system terminal
————————————————
pycharm中导入模块错误时提示Try to run this command from the system terminal

pycharm中导入模块错误时提示Try to run this command from the system terminal

pycharm中导入模块错误时提示Try to run this command from the system terminal

pycharm中导入模块错误时提示Try to run this command from the system terminal

参考该篇博客,在pycharm工作路径中下载安装需要的模块。

pycharm中导入模块错误时提示Try to run this command from the system terminal

pycharm中导入模块错误时提示Try to run this command from the system terminal

根据字面意思理解,一直以为是pip版本不对导致的,于是花费时间在更新pip版本上。根据导入模块时错误提示信息可以看出,我的pycharm路径为D:\u-net segmentation\venv\Scripts。在该径路下打开命令窗口,输入python.exe -m pip install matplotlib -i http://pypi.douban.com/simple --trusted-host pypi.douban.com。(豆瓣国内源)。可以看出,输入完毕后,之前只有numpy、pip以及setuptools三个库,现在多出6个包。一定要在错误中提示的路径下安装导入所需模块。如法炮制,把红色的matplotlib替换成你要安装的库就可以了。

python.exe -m pip install keras -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
python.exe -m pip install tiffile -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
python.exe -m pip install tensorflow -i http://pypi.douban.com/simple --trusted-host pypi.douban.com

至此,花费半个下午的时间终于将需要的库安装成功。

总结

一文看懂荣耀MagicBook Pro 16
荣耀猎人回归!七大亮点看懂不只是轻薄本,更是游戏本的MagicBook Pro 16.
人们对于笔记本电脑有一个固有印象:要么轻薄但性能一般,要么性能强劲但笨重臃肿。然而,今年荣耀新推出的MagicBook Pro 16刷新了人们的认知——发布会上,荣耀宣布猎人游戏本正式回归,称其继承了荣耀 HUNTER 基因,并自信地为其打出“轻薄本,更是游戏本”的口号。
众所周知,寻求轻薄本的用户普遍更看重便携性、外观造型、静谧性和打字办公等用机体验,而寻求游戏本的用户则普遍更看重硬件配置、性能释放等硬核指标。把两个看似难以相干的产品融合到一起,我们不禁对它产生了强烈的好奇:作为代表荣耀猎人游戏本的跨界新物种,它究竟做了哪些平衡以兼顾不同人群的各类需求呢?