AttributeError: module 'discord' has no attribute 'StoreChannel' - python

I'm trying to accommodate slash commands in a discord bot I'm working on and I'm using the discord-ui package for this. I would just like to get some advice on this error and how to fix it
AttributeError: module 'discord' has no attribute 'StoreChannel'
The code is
import discord, os
from discord.ext import commands
from discord_ui import UI, SlashOption
client = commands.Bot(" ")
ui = UI(client)
#ui.slash.command("hello_world", options=[SlashOption(bool, "cool", "whether this libary is cool", required=False)])
async def command(ctx, cool=True):
await ctx.respond("You said this libary is " + str(cool))
for more details on the error:
Traceback (most recent call last):
File "/./Bot1/main.py", line 4, in <module>
from discord_ui import UI, SlashOption
File "/.local/lib/python3.9/site-packages/discord_ui/__init__.py", line 34, in <module>
from .client import *
File "/.local/lib/python3.9/site-packages/discord_ui/client.py", line 1, in <module>
from .cogs import BaseCallable, InteractionableCog, ListeningComponent
File "/.local/lib/python3.9/site-packages/discord_ui/cogs.py", line 5, in <module>
from .slash.types import BaseCommand, ContextCommand, MessageCommand, SlashCommand, SlashSubcommand, UserCommand
File "/.local/lib/python3.9/site-packages/discord_ui/slash/__init__.py", line 20, in <module>
from . import ext
File "/.local/lib/python3.9/site-packages/discord_ui/slash/ext/__init__.py", line 13, in <module>
from .builder import *
File "/.local/lib/python3.9/site-packages/discord_ui/slash/ext/builder.py", line 2, in <module>
from ...enums import CommandType, OptionType
File "/.local/lib/python3.9/site-packages/discord_ui/enums.py", line 13, in <module>
discord.StoreChannel,

Related

Getting multiple error while using flask-ask and ngrok with ROS

I'm trying to use flask-ask library and develope a skill that can make me able to control a robot in ROS with alexa vocal assistant. Python code named "alexa_interface.py" is here.
The skill id number is substituted with my skill id number.
While launching this command
python3 alexa_interface.py
I am getting the following code error.
Tried to install dependencies with pip but getting:
AttributeError: module 'lib' has no attribute 'ERR_load_RAND_strings'
Also notice that I am getting this error everytime I use pip to install something. Is pip broken? How can I adjust this?
Thank you.
#! /usr/bin/env python3
from flask import Flask
from ask_sdk_core.skill_builder import SkillBuilder
from flask_ask_sdk.skill_adapter import SkillAdapter
from ask_sdk_core.dispatch_components import AbstractRequestHandler
from ask_sdk_core.utils import is_request_type, is_intent_name
from ask_sdk_core.handler_input import HandlerInput
from ask_sdk_model import Response
from ask_sdk_model.ui import SimpleCard
app = Flask(__name__)
class LaunchRequestHandler(AbstractRequestHandler):
def can_handle(self, handler_input):
# type: (HandlerInput) -> bool
return is_request_type("LaunchRequest")(handler_input)
def handle(self, handler_input):
# type: (HandlerInput) -> Response
speech_text = "Ciao, come posso aiutarti?"
handler_input.response_builder.speak(speech_text).set_card(
SimpleCard("Hello World", speech_text)).set_should_end_session(
False)
return handler_input.response_builder.response`
skill_builder = SkillBuilder()
# Register your intent handlers to the skill_builder object
skill_builder.add_request_handler(LaunchRequestHandler())
skill_adapter = SkillAdapter(
skill=skill_builder.create(), skill_id="my-skill-id", app=app)
skill_adapter.register(app=app, route="/")
if __name__=='__main__':
app.run()
```
```
Traceback (most recent call last):
File "alexa_interface.py", line 2, in <module>
from flask import Flask
File "/home/toti/.local/lib/python3.8/site-packages/flask/__init__.py", line 14, in <module>
from jinja2 import escape
ImportError: cannot import name 'escape' from 'jinja2' (/home/toti/.local/lib/python3.8/site-packages/jinja2/__init__.py)
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 72, in apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
from apport.report import Report
File "/usr/lib/python3/dist-packages/apport/report.py", line 32, in <module>
import apport.fileutils
File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 12, in <module>
import os, glob, subprocess, os.path, time, pwd, sys, requests_unixsocket
File "/usr/lib/python3/dist-packages/requests_unixsocket/__init__.py", line 1, in <module>
import requests
File "/home/toti/.local/lib/python3.8/site-packages/requests/__init__.py", line 52, in <module>
from .packages.urllib3.contrib import pyopenssl
File "/home/toti/.local/lib/python3.8/site-packages/requests/packages/urllib3/contrib/pyopenssl.py", line 46, in <module>
import OpenSSL.SSL
File "/home/toti/.local/lib/python3.8/site-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "/home/toti/.local/lib/python3.8/site-packages/OpenSSL/rand.py", line 213, in <module>
_lib.ERR_load_RAND_strings()
AttributeError: module 'lib' has no attribute 'ERR_load_RAND_strings'
Original exception was:
Traceback (most recent call last):
File "alexa_interface.py", line 2, in <module>
from flask import Flask
File "/home/toti/.local/lib/python3.8/site-packages/flask/__init__.py", line 14, in <module>
from jinja2 import escape
ImportError: cannot import name 'escape' from 'jinja2' (/home/toti/.local/lib/python3.8/site-packages/jinja2/__init__.py)
```

AttributeError: partially initialized module 'logging' has no attribute 'getLogger' (most likely due to a circular import)

I wrote imports as usual, but it is wrong. I searched and did not find a mistake like mine, please help. The file name is main.py .
Traceback (most recent call last):
File "/app/main.py", line 2, in <module>
from telethon import TelegramClient, Button, events, version
File "/usr/local/lib/python3.9/site-packages/telethon/__init__.py", line 1, in <module>
from .client.telegramclient import TelegramClient
File "/usr/local/lib/python3.9/site-packages/telethon/client/__init__.py", line 12, in <module>
from .telegrambaseclient import TelegramBaseClient
File "/usr/local/lib/python3.9/site-packages/telethon/client/telegrambaseclient.py", line 3, in <module>
import asyncio
File "/usr/local/lib/python3.9/asyncio/__init__.py", line 8, in <module>
from .base_events import *
File "/usr/local/lib/python3.9/asyncio/base_events.py", line 18, in <module>
import concurrent.futures
File "/usr/local/lib/python3.9/concurrent/futures/__init__.py", line 8, in <module>
from concurrent.futures._base import (FIRST_COMPLETED,
File "/usr/local/lib/python3.9/concurrent/futures/_base.py", line 7, in <module>
import logging
File "/usr/local/lib/python3.9/logging/__init__.py", line 28, in <module>
from string import Template
File "/app/string.py", line 7, in <module>
from telethon import TelegramClient, events
File "/usr/local/lib/python3.9/site-packages/telethon/events/__init__.py", line 1, in <module>
from .raw import Raw
File "/usr/local/lib/python3.9/site-packages/telethon/events/raw.py", line 1, in <module>
from .common import EventBuilder
File "/usr/local/lib/python3.9/site-packages/telethon/events/common.py", line 5, in <module>
from .. import utils
File "/usr/local/lib/python3.9/site-packages/telethon/utils.py", line 22, in <module>
from .extensions import markdown, html
File "/usr/local/lib/python3.9/site-packages/telethon/extensions/markdown.py", line 9, in <module>
from ..helpers import add_surrogate, del_surrogate, within_surrogate, strip_text
File "/usr/local/lib/python3.9/site-packages/telethon/helpers.py", line 20, in <module>
_log = logging.getLogger(__name__)
AttributeError: partially initialized module 'logging' has no attribute 'getLogger' (most likely due to a circular import)
I had similar issue, my python file was called token.py. Once I renamed it into something else the problem went away.

Python importing messages module not working

I am trying to parse some protobuf messages and importing the messages module. However getting below error. Not sure what I am missing.
Please advise.
>>> import messages
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.8/dist-packages/messages/__init__.py", line 7, in <module>
from .api import send
File "/usr/local/lib/python3.8/dist-packages/messages/api.py", line 3, in <module>
from .email_ import Email
File "/usr/local/lib/python3.8/dist-packages/messages/email_.py", line 15, in <module>
from ._config import check_config_file
File "/usr/local/lib/python3.8/dist-packages/messages/_config.py", line 12, in <module>
import jsonconfig
File "/usr/local/lib/python3.8/dist-packages/jsonconfig/__init__.py", line 7, in <module>
from .core import Config
File "/usr/local/lib/python3.8/dist-packages/jsonconfig/core.py", line 11, in <module>
from .jsonutils import to_json_file, from_json_file
File "/usr/local/lib/python3.8/dist-packages/jsonconfig/jsonutils.py", line 29, in <module>
to_json = box._to_json
AttributeError: module 'box' has no attribute '_to_json'

Import 'transport' error in asyncio attributes

I am trying to make a discord bot, but I get the following weird error where it can not import asyncio.Transport, although I am able to use it normally outside this code.
The code:
import asyncio
import os
import discord
from dotenv import load_dotenv
The error message:
Traceback (most recent call last):
File "dis.py", line 1, in <module>
import asyncio
File "C:\Users\A.Gawish\AppData\Local\Programs\Python\Python36\lib\asyncio\__init__.py", line 21, in <module>
from .base_events import *
File "C:\Users\A.Gawish\AppData\Local\Programs\Python\Python36\lib\asyncio\base_events.py", line 19, in <module>
import inspect
File "C:\Users\A.Gawish\AppData\Local\Programs\Python\Python36\lib\inspect.py", line 36, in <module>
import dis
File "C:\Users\A.Gawish\dis.py", line 3, in <module>
import discord
File "C:\Users\A.Gawish\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\__init__.py", line 23, in <module>
from .client import Client
File "C:\Users\A.Gawish\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\client.py", line 34, in <module>
import aiohttp
File "C:\Users\A.Gawish\AppData\Local\Programs\Python\Python36\lib\site-packages\aiohttp\__init__.py", line 6, in <module>
from .client import (
File "C:\Users\A.Gawish\AppData\Local\Programs\Python\Python36\lib\site-packages\aiohttp\client.py", line 32, in <module>
from . import hdrs, http, payload
File "C:\Users\A.Gawish\AppData\Local\Programs\Python\Python36\lib\site-packages\aiohttp\http.py", line 7, in <module>
from .http_parser import (
File "C:\Users\A.Gawish\AppData\Local\Programs\Python\Python36\lib\site-packages\aiohttp\http_parser.py", line 14, in <module>
from .base_protocol import BaseProtocol
File "C:\Users\A.Gawish\AppData\Local\Programs\Python\Python36\lib\site-packages\aiohttp\base_protocol.py", line 4, in <module>
from .tcp_helpers import tcp_nodelay
File "C:\Users\A.Gawish\AppData\Local\Programs\Python\Python36\lib\site-packages\aiohttp\tcp_helpers.py", line 20, in <module>
def tcp_keepalive(transport: asyncio.Transport) -> None:
AttributeError: module 'asyncio' has no attribute 'Transport'
Your filename was dis.py, which is used in another module. I resolved a similar issue by ensuring the filename is different from any other existing files in Lib
If you look at your error messages, it is indicating Python36. If Transport in asyncio was only released in Python37, you need to change the pathing in whatever program you're using to write the code in as it's looking at Python36.
Testing it as the command prompt would show that your system sees Python37 but your code doesn't. Fix the pathing and it should work then.

super error while programming a discord BOT with python

I'm new to python, and I was creating a Bot to discord by PyCharm when suddenly there was this giant error below, I already reinstalled python, tried configuring the PATHs for python 3.7 and 3.6, changed IDE and continues giving this error, can anyone help me figure out what's causing this?
error below:
C:\Users\Pichau\AppData\Local\Programs\Python\Python36\python.exe C:/Users/Pichau/Documents/cursos/programacao/Discord/main.py
Traceback (most recent call last):
File "C:/Users/Pichau/Documents/cursos/programacao/Discord/main.py", line 1, in <module>
import discord
File "C:\Users\Pichau\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\__init__.py", line 20, in <module>
from .client import Client, AppInfo, ChannelPermissions
File "C:\Users\Pichau\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\client.py", line 28, in <module>
from .user import User
File "C:\Users\Pichau\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\user.py", line 27, in <module>
from .utils import snowflake_time
File "C:\Users\Pichau\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\utils.py", line 31, in <module>
import asyncio
File "C:\Users\Pichau\AppData\Local\Programs\Python\Python36\lib\asyncio\__init__.py", line 21, in <module>
from .base_events import *
File "C:\Users\Pichau\AppData\Local\Programs\Python\Python36\lib\asyncio\base_events.py", line 17, in <module>
import concurrent.futures
File "C:\Users\Pichau\AppData\Local\Programs\Python\Python36\lib\concurrent\futures\__init__.py", line 8, in <module>
from concurrent.futures._base import (FIRST_COMPLETED,
File "C:\Users\Pichau\AppData\Local\Programs\Python\Python36\lib\concurrent\futures\_base.py", line 7, in <module>
import logging
File "C:\Users\Pichau\AppData\Local\Programs\Python\Python36\lib\logging\__init__.py", line 26, in <module>
import sys, os, time, io, traceback, warnings, weakref, collections
File "C:\Users\Pichau\AppData\Local\Programs\Python\Python36\lib\traceback.py", line 5, in <module>
import linecache
File "C:\Users\Pichau\AppData\Local\Programs\Python\Python36\lib\linecache.py", line 11, in <module>
import tokenize
File "C:\Users\Pichau\AppData\Local\Programs\Python\Python36\lib\tokenize.py", line 41, in <module>
__all__ = token.__all__ + ["COMMENT", "tokenize", "detect_encoding",
AttributeError: module 'token' has no attribute '__all__'
Process finished with exit code 1
Image of error
I would check the code, unless it won’t let you, then you should probably put the code in notepad, and save it then delete the file, and try again. It probably is a computer error more then a coding error.

Categories