Forums

How do I add avconv to my PATH Environment Variable?

I get postactivate in the /bin/ folder, but I have no idea what I'm doing once inside that file. I've tried to Google this to no avail!

ClientException: ffmpeg/avconv was not found in your PATH environment variable

What command is triggering that error? Is it happening when you workon your virtualenv? Or at some other point?

I'm running a Discord bot that utilises youtube_dl to download, and then either ffmpeg or avconv to play. I can download the video using a preset command, but when it reaches the 'play' element, this is triggered.

Where are you running the code? Is it in a console, a web app or a scheduled task?

I have a bot which I run through bash console. The input comes externally, from Discord- but that isn't the issue. I believe the issue is that avconv is not found, and it is a requirement for this to work.

avconv is installed in /usr/bin and that should pretty-much always be on the PATH. You could try using the full path to see if that changes anything.

Hi Glenn, I can't seem to see avconv in either my /usr/bin or my /virtualenv/bin. Any thoughts?

http://prntscr.com/gchg8b

You're not looking it the right place. Neither of those is /usr/bin. The picture is of /home/kitLUL/bin and, unless you or a package you install specifically puts it into your virtualenv, it's not going to be there. It is installed for all users of PythonAnywhere as /usr/bin/avconv.

Ah- understood, cheers. I'm still relatively new to using PythonAnywhere- how would I use the full path in this context?

To add it to the path from a bash console, you'd run this:

export PATH=/usr/bin:$PATH

That would only take effect in the console where you typed it.

That said, it would be really weird if /usr/bin wasn't on your path. What do you get if you run which avconv just before you run the Discord bot? It should print out the location of the command, /usr/bin/avconv

Hi again Giles.
It prints as above, /usr/bin/avconv.

Upon trying to play audio from a Youtube video, I am met with this:

23:47 ~ $ export PATH=user/bin:$PATH
23:48 ~ $ python3.6 Ava/Ava.py
Client logged in.
Voice 4
[youtube] OY-Ec8zX2bw: Downloading webpage
[youtube] OY-Ec8zX2bw: Downloading video info webpage
[youtube] OY-Ec8zX2bw: Extracting video information
[youtube] OY-Ec8zX2bw: Downloading MPD manifest
Ignoring exception in command join
Traceback (most recent call last):
  File "/home/kitLUL/.local/lib/python3.6/site-packages/discord/voice_client.py", line 431, in create_ffmpeg_player
    p = subprocess.Popen(args, stdin=stdin, stdout=subprocess.PIPE, stderr=stderr)
  File "/usr/lib/python3.6/subprocess.py", line 707, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.6/subprocess.py", line 1326, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/home/kitLUL/.local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 50, in wrapped
    ret = yield from coro(*args, **kwargs)
  File "Ava/Ava.py", line 58, in join
    player = await voice.create_ytdl_player(youtube_url)
  File "/home/kitLUL/.local/lib/python3.6/site-packages/discord/voice_client.py", line 541, in create_ytdl_player
    player = self.create_ffmpeg_player(download_url, **kwargs)
  File "/home/kitLUL/.local/lib/python3.6/site-packages/discord/voice_client.py", line 434, in create_ffmpeg_player
    raise ClientException('ffmpeg/avconv was not found in your PATH environment variable') from e
discord.errors.ClientException: ffmpeg/avconv was not found in your PATH environment variable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/home/kitLUL/.local/lib/python3.6/site-packages/discord/ext/commands/bot.py", line 846, in 
process_commands
    yield from command.invoke(ctx)
  File "/home/kitLUL/.local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 374, in invoke
    yield from injected(*ctx.args, **ctx.kwargs)
  File "/home/kitLUL/.local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 54, in wrapped
    raise CommandInvokeError(e) from e
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ClientException: 
ffmpeg/avconv was not found in your PATH environment variable

Apologies- I've fixed the issue.

There was an argument within youtube_dl I wasn't aware of that I didn't have flagged, so it was searching for ffmpeg, as is apparent from the log I linked- I was very tired. Thank you for your help!

Ah, glad you worked it out, especially given that it wasn't giving you the most helpful of error messages!