Ignoring exception in command play: discord.py - discord.py

I get this console error when I try and run the play command.
The code I used is:
#client.command(pass_context=True)
async def play(ctx, url):
guild = ctx.message.guild
voice_client = guild.voice_client
player = await voice_client.create_ytdl_player(url)
players[server.id] = player
player.start()
I have made sure that discord.py, ffmpeg, and youtube_dl are all up to date and I get the same error.

Try to use codeblocks to represent code and errors next time, it'll be easier to view.
You might installed the wrong version of discord.py you need another version for voice clients!
Try reinstall using this pip command:
# Linux/macOS
python3 -m pip install -U "discord.py[voice]"
# Windows
py -3 -m pip install -U discord.py[voice]

Related

dislike_count with pafy and youtube_dl

I have a code for a discord bot that plays music in voice channels
and since youtube removed the dislike counter on video i get an error
nextcord.errors.ApplicationInvokeError: Command raised an exception: KeyError: 'dislike_count'
I tried to change the backend_youtube_dl.py file and it worked, but the thing is I am using Heroku to run the code and I can't change the file there
the code is quite large but this is the part causing the problem
async def play_song(self, interaction, link):
vid = pafy.new(link)
url = vid.getbestaudio().url
interaction.guild.voice_client.play(discord.PCMVolumeTransformer(discord.FFmpegPCMAudio(url)), after=lambda e: self.bot.loop.create_task(self.check_queue(interaction)))
Is there any other way to fix this?
pip install git+https://github.com/mps-youtube/pafy.git
Installs the latest Jul 17, 2021 version which doesn't have the issue you are mentioning, while using pip install pafy installs the Nov 22, 2019 version which has the issue you are mentioning.

`pip` suddenly breaks? with `pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.`

Note.
I know that many solutions have been proposed in this very relevant post but they are all very different and assume vastly different problems, and I don't want to blindly try one at random just to see what happens.
The problem.
I was working on a Jupiter notebook when I started getting errors (with the kernel, cannot quite remember exactly what, now). After trying a few things and searching the web, it seems the problem is that pip broke, somehow. Namely, I am getting the
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available..
error message. Some further reading suggests that the problem is with homebrew?
This puzzles me for two reasons:
- I don't see what I did that broke pip;
- pip for all of my virtual environments seem broken.
What is the problem, really, and where does it come from?
Setup.
- macOS Catalina 10.15.3.
- pyenv as Python virtual environment manager
- outputs below for Python and pip versions
Some outputs.
The command pip --version with python3.8.2 is very strange. Going through the site-packages of the python3.8.2 install, it looks like pip version is 19.2.3.
The errors are not the quite the same for the different versions of pip.
$ pyenv local 3.6.7 && pip --version && pip list
pip 10.0.1 from /Users/antoine/.pyenv/versions/3.6.7/lib/python3.6/site-packages/pip (python 3.6)
# prints list correctly
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.",)) - skipping
$ pyenv local 3.7.1 && pip --version && pip list
pip 10.0.1 from /Users/antoine/.pyenv/versions/3.7.1/lib/python3.7/site-packages/pip (python 3.7)
# prints list correctly
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
$ pyenv local 3.7.4 && pip --version && pip list
pip 19.3.1 from /Users/antoine/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pip (python 3.7)
# prints list correctly
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
$ pyenv local 3.8.2 && pip --version # produces error, no need to try `pip list`
# prints something that looks like ImageMagick help documentation
By default, 'file' is written in the MIFF image format. To
specify a particular image format, precede the filename with an image
format name and a colon (i.e. ps:image) or specify the image type as
the filename suffix (i.e. image.ps). Specify 'file' as '-' for
standard input or output.
import: delegate library support not built-in '' (X11) # error/import.c/ImportImageCommand/1282.
from: can't read /var/mail/pip._internal
/Users/antoine/.pyenv/versions/3.8.2/bin/pip: line 9: syntax error near unexpected token `('
/Users/antoine/.pyenv/versions/3.8.2/bin/pip: line 9: ` sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])'

Uninstall module form command line odoo10

I tried to uninstall my custom module by using
'./odoo.py -d db_name --uninstall module_name(s)' command.
But I get the error:
'bash: ./odoo.py: No such file or directory'
How can I fix it? How can i know a module is installed or not?
Thanks
In odoo 12, I ran the below command in psql:
UPDATE ir_module_module SET state = 'to remove' WHERE name = 'app_library';
Once its updated, restart the odoo server:
python odoo-bin -d demodb (windows)
./odoo-bin -d demodb (linux)
The module installed before is completely uninstalled.
Try executing this command:
UPDATE ir_module_module SET state = 'uninstalled' WHERE name = 'module_name';
in postgres.
There is no any possible option now to uninstall the odoo module directly from the command prompt.
You can also see another option for help further for additional commands using
./odoo-bin --help
Which gives you the list of additional option with addons-path

bash: kivy: command not found

I followed the instructions in this link about Kivy installation "Using Homebrew with pip".
However, when I tried to run the code given below:
from kivy.app import App
from kivy.uix.button import Button
class TestApp(App):
def build(self):
return Button(text='Hello World')
TestApp().run()
It gave me an error:
bash: kivy: command not found
if you installed kivy with pip, you don't need a kivy command, you can use python directly.
python main.py
Because I created a virtual environment to isolate all the things that needs to be installed like kivy, and I installed cython and kivy first before the homebrew, it caused the problem. Even if I use:
python main.py
instead of
kivy main.py
What I did to solve it are the following:
1. Created a new virtual environment
2. Followed the instruction in kivy in right order: (1) homebrew, (2) Cython, then (3) Kivy.
3. Used "python" command instead of "kivy" command because I installed it using pip (refer to the commenr above). For example:
python name_of_your_file.py
Kivy documentation must be confusing that's why.

Making MITM proxy run on Mac

I need to make use of python's mitmproxy. I have installed it successfully. However when I run mitmproxy command on my terminal it gives me a stack trace like the below :
File "/usr/local/bin/mitmproxy", line 9, in load_entry_point('mitmproxy==0.13', 'console_scripts','mitmproxy'()
File "/Library/Python/2.7/site-packages/pkg_resources/init.py", line 558, in load_entry_pointreturn get_distribution(dist).load_entry_point(group, name)
File "/Library/Python/2.7/site-packages/pkg_resources/init.py", line 2682, in load_entry_point return ep.load()
File "/Library/Python/2.7/site-packages/pkg_resources/init.py", line 2355, in load return self.resolve()
File "/Library/Python/2.7/site-packages/pkg_resources/init.py", line 2361, in resolve module = import(self.module_name, fromlist=['name'], level=0)
File "/Library/Python/2.7/site-packages/libmproxy/main.py", line 7, in from . import version, cmdline
File "/Library/Python/2.7/site-packages/libmproxy/cmdline.py", line 5, in from netlib import http
File "/Library/Python/2.7/site-packages/netlib/http.py", line 7, in from . import odict, utils, tcp, http_status
File "/Library/Python/2.7/site-packages/netlib/tcp.py", line 26, in 'TLSv1.2': SSL.TLSv1_2_METHOD, AttributeError: 'module' object has no attribute 'TLSv1_2_METHOD'
I tried debugging the issue through some Googling and looks like I needed to upgrade my pyOpenSSL.
To know the current version of my PyOpen SSL I did the following on the Python prompt and got the ouptut as shown below to be 0.13:
>>> import OpenSSL
>>> print OpenSSL.__version__
0.13
So I tried upgrading the my pyOpenSSL using the below :
sudo pip install --upgrade pyOpenSSL
ans successfully did so, as when I ran the above again I received the following in the first line of the output :
Requirement already up-to-date: pyOpenSSL in /Library/Python/2.7/site-packages
Just to cross verify I went to the above path and found the PyOpenSSL dir as PyOpenSSL-0.15.1.dist-info. So am guessing PyOpenSSL was actually upgraded to the latest version.
However, when I ran the below on Python prompt again I received the version again as 0.13. Ideally I was expecting it to give the updated version now.
>>> import OpenSSL
>>> print OpenSSL.__version__
0.13
Some blogs suggested that if I have a virtualevn installed, it might interfere with the above. So I uninstalled virtualenv as well using
sudo pip uninstall virtualenv
I am still not able to get mitmproxy running. And when I run mitmproxy, I still get the same error as above.
Please let me know what am I missing and how to get mitmproxy running.
So it happens yet again. :P I could figure out the problem with the above approach and the solution to it as well on my own - OF COURSE - with the help of some friends and blogs !
So appears that the problem was actually because of MANY out-dated dependencies : -
Outdated OpenSSL -
current version displayed using OpenSSL version -a
Awesome help found # http://javigon.com/2014/04/09/update-openssl-in-osx/ to update OpenSSL and from a friend (https://anantshri.info/) who pointed out the issue itself initially.
Outdated pyOpenSSL - upgraded using the below which of course upgraded the same.
sudo pip install --upgrade pyOpenSSL
Then why was the below still showing an outdated version ?
import OpenSSL
print OpenSSL.version
0.13
because there were 2 different OpenSSLs in the system. One that was installed by pip and the other that was by default present in OSX. Again awesome help found # https://github.com/pyca/pyopenssl/issues/128
some useful commands that helper were :
pip show pyOpenSSL - gives as output :
Name: pyOpenSSL
Version: 0.15.1
Location: /Library/Python/2.7/site-packages
as part of the output - indicating that the OpenSSL installed using pip is actually 0.15.1
cross verify using :
ls /Library/Python/2.7/site-packages/ | grep OpenSSL - gives as output:
pyOpenSSL-0.15.1.dist-info
Now the path below also had another copy of OpenSSL :
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/OpenSSL and cat version.py in the above dir gave the below as part of output :
version = '0.13.1'
indicating that the cause of the issue with the import statement showing the outdated python version.
And the above itself was the root cause for mitmproxy also not working
because mitmproxy was unable to use the latest version on OpenSSL.
So solved the problem by just replacing the OpenSSL in the above path (which was outdated) with the updated one from /Library/Python/2.7/site-packages/
where
cat ./OpenSSL/version.py gave as output (once again just to cross-verify)
version = '0.15.1'
And now the import statement reported the right version of OpenSSL.
Uninstalled mitmproxy using sudo pip uninstall mitmproxy - successfully uninstalled. Also uninstalled virtualenv. (not sure of the above 2 was required !)
Reinstalled mitmproxy as sudo pip install mitmproxy - Successfully done !
And ran mitmproxy now from the terminal wihtout a glitch ! :)

Resources