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

Error When Importing to File #1592

Closed
kgoetke opened this issue Sep 18, 2018 · 12 comments
Closed

Error When Importing to File #1592

kgoetke opened this issue Sep 18, 2018 · 12 comments

Comments

@kgoetke
Copy link

kgoetke commented Sep 18, 2018

I'm trying to make a really basic Discord bot using the reply.py example, but whenever I run it, the terminal says 'TypeError: Cannot change parameter count from 2 to 1'. Any suggestions?

@Harmon758
Copy link
Contributor

You need to provide the full traceback and any relevant code for someone to help you.

@kgoetke
Copy link
Author

kgoetke commented Sep 18, 2018

What does traceback mean? (sorry, I'm new to all this)

@Harmon758
Copy link
Contributor

It's usually difficult, if not impossible, to determine what the problem is based on only the error type and message itself. You need to provide the entire traceback of the code that the error type and message are a part of, as well as any code that was used that caused the error, so that the issue can be debugged.

@kgoetke
Copy link
Author

kgoetke commented Sep 18, 2018

Here's my code (and yes, I did change TOKEN to the actual token):

import discord

client = discord.Client()

@client.event
async def on_message(message):
# we do not want the bot to reply to itself
if message.author == client.user:
return

if message.content.startswith('!hello'):
    msg = 'Hello {0.author.mention}'.format(message)
    await client.send_message(message.channel, msg)

@client.event
async def on_ready():
print('Logged in as')
print(client.user.name)
print(client.user.id)
print('------')

client.run('TOKEN')

@kgoetke
Copy link
Author

kgoetke commented Sep 18, 2018

Here's the full error from my terminal:

Traceback (most recent call last):
File "C:\Users\Kyle.Kyle-PC\Desktop\fun\Python\discord_bot\discordbot.py", line 3, in
import discord
File "C:\Users\Kyle.Kyle-PC\AppData\Local\Programs\Python\Python\lib\site-packages\discord_init_.py", line 20, in
from .client import Client, AppInfo, ChannelPermissions
File "C:\Users\Kyle.Kyle-PC\AppData\Local\Programs\Python\Python\lib\site-packages\discord\client.py", line 42, in
from .voice_client import VoiceClient
File "C:\Users\Kyle.Kyle-PC\AppData\Local\Programs\Python\Python\lib\site-packages\discord\voice_client.py", line 65, in
from .gateway import *
File "C:\Users\Kyle.Kyle-PC\AppData\Local\Programs\Python\Python\lib\site-packages\discord\gateway.py", line 31, in
import aiohttp
File "C:\Users\Kyle.Kyle-PC\AppData\Local\Programs\Python\Python\lib\site-packages\aiohttp_init_.py", line 4, in
import multidict # noqa
File "C:\Users\Kyle.Kyle-PC\AppData\Local\Programs\Python\Python\lib\site-packages\multidict_init_.py", line 18, in
from ._abc import MultiMapping, MutableMultiMapping
File "C:\Users\Kyle.Kyle-PC\AppData\Local\Programs\Python\Python\lib\site-packages\multidict_abc.py", line 33, in
MultiMapping[_T],
File "C:\Users\Kyle.Kyle-PC\AppData\Local\Programs\Python\Python\lib\typing.py", line 970, in getitem
(len(self.parameters), len(params)))
TypeError: Cannot change parameter count from 2 to 1

@Harmon758
Copy link
Contributor

This is an issue with multidict, a dependency for discord.py, not discord.py itself.
What version of Python are you using?

@kgoetke
Copy link
Author

kgoetke commented Sep 18, 2018

That might be the issue... I recently upgraded from 3.5.1 to 3.7, but PowerShell is running 3.5.1. How can I fix this?

@scragly
Copy link
Contributor

scragly commented Sep 18, 2018

Discord.py 0.16 (async branch) is not compatible with Python 3.7
Also powershell and command prompt allow the same launch command py with the ability to specify the python interpreter you wish to use: e.g. py -3.5.
By default it will use the most recently installed version, typically, or at least whatever is the highest in the PATH environmental variable. You can test what the default is with py --version.

@kgoetke
Copy link
Author

kgoetke commented Sep 18, 2018

When I do py --version, it says 3.7, but when I run files, it says 3.5.1

@Harmon758
Copy link
Contributor

Harmon758 commented Sep 18, 2018

In that case, this is likely related to aio-libs/multidict#286.
If you want to continue using Python 3.5, your options are to either update to Python >= 3.5.3, downgrade to multidict >= 2.0, < 4.4.1 (e.g. 4.4.0), or wait to see if a future update to multidict maintains support for older Python versions < 3.5.3.

However, if you want to use Python 3.7, you'll likely encounter issues with the current async branch.
See #1249 and #1401 for your options.

As for specifying the Python version on Windows, see https://docs.python.org/3/using/windows.html#python-launcher-for-windows.

For further help using the library, you should join either the official discord.py server or the Discord API server, as the README recommends.

@scragly
Copy link
Contributor

scragly commented Sep 18, 2018

Just a side-note, it's recommended to specify the interpreter you're running your script through explicitly; by the sounds of your previous statement, you 'run files', which means you're likely running the py file itself without specifying an interpreter.

When running your py file, to specify what interpreter you can run it like: py -3.5 mypyfile.py
And when installing packages, you can install explicitly with py -3.5 -m pip install packagename to ensure the package is going to python 3.5 for example, while py -m pip install packagename goes to 3.7 since you verified it's the default.

If you upgrade your python from 3.5.1 to resolve the main issue at hand, I would recommend you look into one of the newer 3.6 versions if you're wanting to keep using discord.py 0.16 (async branch), as it's compatible, and it comes with a few extra bonus', one especially being fstrings.

@Harmon758
Copy link
Contributor

This should now be fixed with multidict 4.4.2.

@kgoetke kgoetke closed this as completed Sep 23, 2018
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

3 participants