导入请求 ModuleNotFoundError: 没有名为“请求”的模块

时间:2021-04-22 08:26:33

标签: python python-import

我需要运行此代码,但发现此错误:

Traceback (most recent call last):
  File "C:\Users\DELL\Downloads\snapArt.py", line 1, in <module>
    import requests
ModuleNotFoundError: No module named 'requests'

代码:

import requests
from hashlib import sha256
from time import time, sleep

print("""


""")

FielUser = open('Users.txt' , 'r').read().splitlines()

req = requests.session()

def token():
    for i, c in enumerate("0001110111101110001111010101111011010001001110011000110001000110"):
        if c == "0":
            yield sha256(("iEk21fuwZApXlz93750dmW22pw389dPwOk"+"m198sOkJEn37DjqZ32lpRu76xmw288xSQ9").encode('utf-8')).hexdigest()[i]
        else:
            yield sha256((str(int(round(time() * 1000.0))) + "iEk21fuwZApXlz93750dmW22pw389dPwOk").encode('utf-8')).hexdigest()[i]



for user in FielUser:

    if user:
        user = user.strip()

        url = 'https://app.snapchat.com/loq/suggest_username_v2'

        headers = {'User-Agent':'Snapchat/10.25.0.0 (Agile_Client_Error; Android 5.1.1#500181103#22; gzip)'}

        data = {
            'req_token': "".join(list(token())),
            'requested_username': user,
            'timestamp': int(round(time() * 1000.0)),
            'status_code': ''
        }

        res = req.post(url, headers=headers, data=data)

        if res:
            JSON = res.json()
            #print(JSON)

            if JSON.get('requested_username') and JSON.get('status_code') == 'OK':
                with open('Found.txt', "a+") as file_save:
                    file_save.write(user + '\n')
                print('available ->', user)
                sleep(1)
            else:
                print('not available ->', user)
                sleep(1)

print('''

''')

1 个答案:

答案 0 :(得分:1)

  1. 确保您不在虚拟环境 (venv) 中。这可能是您的问题之一。

  2. 您不会安装名为 requests 的模块。为此,只需打开您的 cmd(命令提示符)或终端并输入 pip install requests