如何解決requests,已經(jīng)安裝卻無法import問題
requests已經(jīng)安裝卻無法import
已經(jīng)pip install requests,后面在pycharm里卻無法import requests,
已經(jīng)排除不是環(huán)境變量配置問題
在python console里面import requests,
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:\Program Files\PyCharm\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
ModuleNotFoundError: No module named 'requests'
報上面這個錯誤。
后面百度到,可以在pycharm里面直接下載安裝需要的庫,不用每次在cmd里面區(qū)pip install ***
方法:
點擊File->settings ->Project Interpreter ,點擊右方的+號,在搜索欄搜索requests,點擊安裝,等待安裝完畢即可。
Python之Request庫的安裝、安裝卻無法import、"You should consider upgrading via the 'python -m pip....."
方法一:pip install requests
我在安裝的時候出現(xiàn)了,**“You should consider upgrading via the ‘python -m pip install --upgrade pip’ command.”**的情況。
我當(dāng)時跟著打來著,結(jié)果報錯了。應(yīng)該是 ‘-’ 輸入有誤,建議直接復(fù)制
終于顯示了:Successfully installed pip
不放心的可以檢查一下。
輸入:pip show pip
方法二
點擊File->settings ->Project Interpreter ,點擊右方的+號,在搜索欄搜索requests,點擊安裝。
安裝卻無法import
我是用方法一安裝的,安裝成功后,用IDLE檢查,import requests成功了,但是回到pycharm里import requests卻報錯。于是直接在pycham里使用方法二安裝,就成功了。
檢查安裝是否成功
>>> import requests >>> r = requests.get("http://www.baidu.com") >>> print(r.status_code) 200 >>> r.text '<!DOCTYPE html>\r\n<!--STATUS OK--><html> <head><meta http-equiv=content-type content=text/html;charset=utf-8><meta http-equiv=X-UA-Compatible content=IE=Edge><meta content=always name=referrer><link rel=stylesheet type=text/css href=http://s1.bdstatic.com/r/www/cache/bdorz/baidu.min.css><title>?\x99??o|??\x80??\x8b??\x8c??\xa0?°±?\x9f¥é\x81\x93</title></head> <body link=#0000cc> <div id=wrapper> <div id=head> <div class=head_wrapper> <div class=s_form> <div class=s_form_wrapper> <div id=lg> <img hidefocus=true src=//www.baidu.com/img/bd_logo1.png width=270 height=129> </div> <form id=form name=f action=//www.baidu.com/s class=fm> <input type=hidden name=bdorz_come value=1> <input type=hidden name=ie value=utf-8> <input type=hidden name=f value=8> <input type=hidden name=rsv_bp value=1> <input type=hidden name=rsv_idx value=1> <input type=hidden name=tn value=baidu><span class="bg s_ipt_wr"><input id=kw name=wd class=s_ipt value maxlength=255 autocomplete=off autofocus></span><span class="bg s_btn_wr"><input type=submit id=su value=?\x99??o|??\x80??\x8b class="bg s_btn"></span> </form> </div> </div> <div id=u1> <a href=http://news.baidu.com name=tj_trnews class=mnav>?\x96°é\x97?</a> <a href=http://www.hao123.com name=tj_trhao123 class=mnav>hao123</a> <a href=http://map.baidu.com name=tj_trmap class=mnav>?\x9c°?\x9b?</a> <a href=http://v.baidu.com name=tj_trvideo class=mnav>è§\x86é¢\x91</a> <a href=http://tieba.baidu.com name=tj_trtieba class=mnav>è′′?\x90§</a> <noscript> <a href=http://www.baidu.com/bdorz/login.gif?login&tpl=mn&u=http%3A%2F%2Fwww.baidu.com%2f%3fbdorz_come%3d1 name=tj_login class=lb>?\x99???\x95</a> </noscript> <script>document.write(\'<a + encodeURIComponent(window.location.href+ (window.location.search === " rel="external nofollow" " ? "?" : "&")+ "bdorz_come=1")+ \'" name="tj_login" class="lb">?\x99???\x95</a>\');</script> <a href=//www.baidu.com/more/ name=tj_briicon class=bri style="display: block;">?\x9b′?¤\x9a?o§?\x93\x81</a> </div> </div> </div> <div id=ftCon> <div id=ftConw> <p id=lh> <a href=http://home.baidu.com>?\x853?o\x8e?\x99??o|</a> <a href=http://ir.baidu.com>About Baidu</a> </p> <p id=cp>©2017 Baidu <a href=http://www.baidu.com/duty/>????\x94¨?\x99??o|?\x89\x8d??\x85èˉ?</a> <a href=http://jianyi.baidu.com/ class=cp-feedback>?\x84\x8fè§\x81?\x8f\x8dé|\x88</a> ?o?ICPèˉ\x81030173?\x8f· <img src=//www.baidu.com/img/gs.gif> </p> </div> </div> </div> </body> </html>\r\n'
總結(jié)
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
基于TensorBoard中g(shù)raph模塊圖結(jié)構(gòu)分析
今天小編就為大家分享一篇基于TensorBoard中g(shù)raph模塊圖結(jié)構(gòu)分析,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-02-02python中三種高階函數(shù)(map,reduce,filter)詳解
在Python中,函數(shù)其實也是一種數(shù)據(jù)類型,今天重點給大家介紹python中三種高階函數(shù)(map,reduce,filter)的相關(guān)知識,感興趣的朋友一起看看吧2021-10-10用python基于appium模塊開發(fā)一個自動收取能量的小助手
大家都有了解過螞蟻森林吧,本篇文章帶給你自動收取螞蟻森林能量的思路與方法,基于appium模塊開發(fā)一個自動收取能量的小助手,本文給大家介紹的非常詳細,對大家的學(xué)習(xí)或工作具有一定的價值2021-09-09Python實現(xiàn)九宮格式的朋友圈功能內(nèi)附“馬云”朋友圈
PIL(Python Imaging Library)是一個非常強大的Python庫,但是它支持Python2.X, 在Python3中則使用的是Pillow庫,它是從PIL中fork出來的一個分支。這篇文章主要介紹了用Python搞定九宮格式的朋友圈功能內(nèi)附“馬云”朋友圈 ,需要的朋友可以參考下2019-05-05