Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError 'TextStyle' from 'discord' #51

Closed
jennck opened this issue May 23, 2022 · 10 comments
Closed

ImportError 'TextStyle' from 'discord' #51

jennck opened this issue May 23, 2022 · 10 comments

Comments

@jennck
Copy link

jennck commented May 23, 2022

Getting this ImportError while trying to set up bot.

/Downloads/Valorant-DiscordBot-master/utils/valorant/view.py", line 5, in <module> from discord import Interaction, TextStyle, ui ImportError: cannot import name 'TextStyle' from 'discord' (/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/__init__.py)

@staciax
Copy link
Owner

staciax commented May 23, 2022

i think discord.py old version
pls update pip install git+https://github.com/Rapptz/discord.py@master

@jennck
Copy link
Author

jennck commented May 23, 2022

still getting the same error

@staciax
Copy link
Owner

staciax commented May 23, 2022

wait wait

pls pip list and screenshot

@jennck
Copy link
Author

jennck commented May 23, 2022

Screen Shot 2022-05-23 at 1 08 57 AM

@staciax
Copy link
Owner

staciax commented May 23, 2022

You have 3 library disords, they can't be used at the same time.

pip uninstall discord
pip uninstall py-cord
pip install --force-reinstall git+https://github.com/Rapptz/discord.py@master
image

@jennck
Copy link
Author

jennck commented May 23, 2022

have no clue what any of this means, but i'm getting a new error

`Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/aiohttp/connector.py", line 986, in _wrap_create_connection
return await self._loop.create_connection(*args, **kwargs) # type: ignore[return-value] # noqa
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 1089, in create_connection
transport, protocol = await self._create_connection_transport(
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 1119, in _create_connection_transport
await waiter
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/sslproto.py", line 534, in data_received
ssldata, appdata = self._sslpipe.feed_ssldata(data)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/sslproto.py", line 188, in feed_ssldata
self._sslobj.do_handshake()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 974, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/Users/jenniferkim/Downloads/Valorant-DiscordBot-master/bot.py", line 74, in
run_bot()
File "/Users/jenniferkim/Downloads/Valorant-DiscordBot-master/bot.py", line 71, in run_bot
asyncio.run(bot.start())
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
return future.result()
File "/Users/jenniferkim/Downloads/Valorant-DiscordBot-master/bot.py", line 67, in start
return await super().start(os.getenv('TOKEN'), reconnect=True)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/client.py", line 706, in start
await self.login(token)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/client.py", line 560, in login
data = await self.http.static_login(token.strip())
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/http.py", line 558, in static_login
data = await self.request(Route('GET', '/users/@me'))
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/discord/http.py", line 441, in request
async with self.__session.request(method, url, **kwargs) as response:
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/aiohttp/client.py", line 1138, in aenter
self._resp = await self._coro
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/aiohttp/client.py", line 535, in _request
conn = await self._connector.connect(
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/aiohttp/connector.py", line 542, in connect
proto = await self._create_connection(req, traces, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/aiohttp/connector.py", line 907, in _create_connection
_, proto = await self._create_direct_connection(req, traces, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/aiohttp/connector.py", line 1206, in _create_direct_connection
raise last_exc
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/aiohttp/connector.py", line 1175, in _create_direct_connection
transp, proto = await self._wrap_create_connection(
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/aiohttp/connector.py", line 988, in _wrap_create_connection
raise ClientConnectorCertificateError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host discord.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)')]
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x1026cb7c0>`

@staciax
Copy link
Owner

staciax commented May 23, 2022

#42 (comment)

@jennck
Copy link
Author

jennck commented May 23, 2022

Tried importing the two certificate links, and I also tried following the youtube tutorial linked using Securly's certificate, but they all did not work.

  • For the first two certificate links '2835394' and '6178581089', I received this image below. For Securly's certificate, it imported but when I ran the cmd 'python3 bot.py' I got the same initial error.

Screen Shot 2022-05-23 at 1 38 55 AM

@staciax
Copy link
Owner

staciax commented May 23, 2022

I have never had an error
SSLCertVerificationError
So I don't know the root cause of the problem.

You may need to run the bot on another platform.

@jennck
Copy link
Author

jennck commented May 23, 2022

found the solution. i forgot to run '/Applications/Python\ 3.10/Install\ Certificates.command' (i thought i already ran it before, but i did not). thank you for your help.

@jennck jennck closed this as completed May 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants