简体   繁体   中英

ImportError: cannot import name 'post' from 'request' (C:\Program Files\Python37\lib\site-packages\request\__init__.py)

I want to post my code result to an IoT Platform but whenever i'm trying to post the output it's giving me: ImportError: cannot import name 'post' from 'request' (C:\\Program Files\\Python37\\lib\\site-packages\\request__init__.py)

is it my package is unusable? or is there any other way to fix this error? here is my code

hasil = [2,1,1,1,1,2,2,2,1] 
x = [3,4,2,5,3,4,3,7,6]
import request
from request import post
for e in range (0,len(x)):
            if hasil ==1:
                    q = '{"\nStatus: Tidak Banjir"}'
                    o = json.dumps(q)
                    data = '\r\n{\r\n  "m2m:cin": {\r\n    "cnf": "message",\r\n    "con": "\r\n      {\r\n      \t \\"Status\\": \\"'+str(o)+'\\",\r\n}}}' 
                    url = 'https://platform.antares.id:8443/~/antares-cse/antares-id/FloodForecasting/WeatherData'
                    headers = {'cache-control':'no-cache','content-type':'application/json;ty=4','x-m2m-origin':'7c4f123fd1ba4737:3fc88dbc74b9c905'}
                    r = request.post(url,headers=headers,data=data)
            elif hasil==2:
                    q = '{"\nStatus: Tidak Banjir"}'
                    o = json.dumps(q)
                    #print(o)
                    data = '\r\n{\r\n  "m2m:cin": {\r\n    "cnf": "message",\r\n    "con": "\r\n      {\r\n      \t \\"Status\\": \\"'+str(o)+'\\",\r\n' 
                    url = 'https://platform.antares.id:8443/~/antares-cse/antares-id/FloodForecasting/WeatherData'
                    headers = {'cache-control':'no-cache','content-type':'application/json;ty=4','x-m2m-origin':'7c4f123fd1ba4737:3fc88dbc74b9c905'}
                    r = request.post(url,headers=headers,data=data)

程序包名称是请求而不是请求。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

Related Question import MySQLdb报错ImportError: cannot import name '_mysql' from 'MySQLdb' (D:\python\lib\site-packages\MySQLdb\__init__.py) importerror: cannot import name 'dump' from 'dump' (~/.local/lib/python3.8/site-packages/dump/__init__.py) Error: from matplotlib import _png ImportError: cannot import name '_png' from 'matplotlib' (C:\\Garden\lib\site-packages\matplotlib\__init__.py) ImportError: cannot import name 'TwitterRestPager' from 'TwitterAPI' (C:\Users\My name \Anaconda3\lib\site-packages\TwitterAPI\__init__.py) ImportError: cannot import name 'set_random_seed' from 'tensorflow' (C:\Users\polon\Anaconda3\lib\site-packages\tensorflow\__init__.py) ImportError: cannot import name 'logsumexp' from 'scipy.misc' (C:\Users\firstname.lastname\Anaconda3\lib\site-packages\scipy\misc\__init__.py) ImportError: cannot import name 'CypherError' from 'neo4j.v1' (/usr/local/lib/python3.7/site-packages/neo4j/v1/__init__.py) ImportError: cannot import name '_message' from 'google.protobuf.pyext' (c:\programdata\anaconda3\lib\site-packages\google\protobuf\pyext\__init__.py) Django2.1.7 ImportError: cannot import name 'util' from 'django.forms' (/Users/lib/python3.7/site-packages/django/forms/__init__.py) ImportError: cannot import name 'Deconvolution3D' from 'keras.layers' (/home/mona/venv/fall/lib/python3.8/site-packages/keras/layers/__init__.py)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM