3
import discord
import pynacl

client = discord.Client()

@client.event
async def on_ready():
    print('We have logged in as {0.user}'.format(client))

@client.event
async def on_message(message):
    if message.author == client.user:
        return
    if message.content.startswith('$'):
        if message.author.voice:
            await message.author.voice.channel.connect()
        return await message.channel.send(message.author.voice.channel)

After starting the program, an error appears ModuleNotFoundError: No module named 'pynacl'. It is important to note that pynacl is already in the module list. When I reinstall the module pip install PyNaCl/pip3 install PyNaCl, the console says the module is already loaded.

Tried: Reload IDLE and computer, tried import nacl (ModuleNotFoundError: No module named 'nacl'), and not import pynacl, reinstall module, and also used import discrod.py[voice]. If the module is not imported, it displays the following error: RuntimeError: PyNaCl library needed in order to use voice.

I am using IDLE Python 3.7.1

alxbavy
  • 160
  • 2
  • 11
  • Sounds like a mismatch between python versions and pip/pip3 using other versions than your specific python version, I would try installing the modules via `python3.7 -m pip install xxx` or whichever python binary is actually being used. – Jason Rebelo Neves Feb 16 '21 at 10:52
  • Console error: "python3.7" is not internal or external command, executable program, or batch file. – alxbavy Feb 16 '21 at 11:06
  • I would recommend you to use PyCharm, where these problems are solved automatically – Vega TV Feb 16 '21 at 11:10
  • 1
    You can try `python -m pip install xxx` or `python3 -m pip install xxx`, you can also check which versions these python binaries are by running `python --version` or `python3 --version` – Jason Rebelo Neves Feb 16 '21 at 11:13
  • I tried ```python3 --version```. Output: python 3.6.7. And I'm using version 3.7.1. – alxbavy Feb 16 '21 at 11:17
  • 1
    Inside the IDLE, do `python3 --version`. If it says 3.7.1 then try run `python3.7.1 -m pip install PyNaCl` – Kelo Feb 16 '21 at 11:53
  • 1
    If you're on Windows you will probably have to either modify the environment variables as explained here: https://stackoverflow.com/a/52913040/13042738, OR you can try the same process as before but with the `py` command, which to my knowledge on windows uses the most recently installed version of python. – Jason Rebelo Neves Feb 16 '21 at 11:58

1 Answers1

1

In short, I figured it out. Thanks to everyone who took part in the discussion of the issue. The problem was that the Windows console was "tied" to the Python 3.6.7 version, and all modules were installed on it, and I was working in 3.7.1, hence the error.

As fixed:

  1. Checked python3 --version and found that the console is tied to it.
  2. Removed Python 3.6.7 version.
  3. Faced the problem "Fatal error in launcher".
  4. Removed the Python 3.6 folder from AppData\Local\Programs\Python.
  5. Updated pip and downloaded pynacl. Done! :D
alxbavy
  • 160
  • 2
  • 11