Cannot install opus on replit in python

Question:
So I have recently restarted my discord.py bot, and I am trying to fix all of the errors that keep popping up. One of them was that youtube_dl was simply not downloading the Youtube video to be played in the vc. I switched to yt-dlp, which I was told is a good alternative for yt-dl. That had its own problems. It requires opus to play the music, which I tried using

discord.opus.load_opus("opus")

It gave an error: Command raised an exception: OSError: opus: cannot open shared object file: No such file or directory
I looked it up, it meant that I had to download opus in replit. I found a replit topic (https://replit.com/talk/learn/OPUS-SUPPORT-FOR-DISCORD-MUSIC-BOTS/37015?order=new) which mentioned to use PHP. I typed PHP in the shell, which prompted me to select a version of PHP to run:

~/Discord-Bot-Again$ php
php: command not installed. Multiple versions of this command were found in Nix.
Select one to run (or press Ctrl-C to cancel):
>
php74.out
apacheHttpdPackages.php.out

Selecting either one of those results in the same output:

Adding apacheHttpdPackages.php to replit.nix
success
/nix/store/rww35k8k15aa0szakc6zv3racm5yi75y-php-with-extensions-8.0.8
^C
Detected change in environment, reloading shell...
nix error: building nix env: exit status 1
Output has been trimmed to the last 20 lines
instantiated 'php-simplexml-8.1.13' -> '/nix/store/kwnykbhazv6qi12r48kfffh6b3n77c7j-php-simplexml-8.1.13.drv'
instantiated 'php-sockets-8.1.13' -> '/nix/store/v4agja02jqlblc09qwi2pgjgmm8wwmil-php-sockets-8.1.13.drv'
instantiated 'php-soap-8.1.13' -> '/nix/store/c9ir5v375z4wvg9z230nh31swh2nsm48-php-soap-8.1.13.drv'
instantiated 'php-sodium-8.1.13' -> '/nix/store/i90mrjk4j9hq450ffzrhzsjv7apcgwyv-php-sodium-8.1.13.drv'
instantiated 'php-sysvsem-8.1.13' -> '/nix/store/77sjrmmihqmlb08s5rwvcy90il8nqd0d-php-sysvsem-8.1.13.drv'
instantiated 'php-sqlite3-8.1.13' -> '/nix/store/cq74k6iqg1sis13rciwxmb9fahdmj16v-php-sqlite3-8.1.13.drv'
copied source '/nix/store/l6smcclpy9f3v562q2ljb9zjdswg3ma1-nixpkgs-22.11-src/pkgs/development/interpreters/php/fix-tokenizer-php81.patch' -> '/nix/store/xvdqq71cvvy7m084q5qznnn6cdp16yri-fix-tokenizer-php81.patch'
instantiated 'php-tokenizer-8.1.13' -> '/nix/store/hxls00rdrqh5rkvxy07vrvarq28i9izy-php-tokenizer-8.1.13.drv'
instantiated 'php-xmlreader-8.1.13' -> '/nix/store/d674cgyqhyy6yd7k2spjbnmmk87mnqzq-php-xmlreader-8.1.13.drv'
instantiated 'php-xmlwriter-8.1.13' -> '/nix/store/k00qk389lrg10rfq6nwxw6k1lyjnk3dx-php-xmlwriter-8.1.13.drv'
evaluating file '/nix/store/l6smcclpy9f3v562q2ljb9zjdswg3ma1-nixpkgs-22.11-src/pkgs/development/libraries/libzip/default.nix'
instantiated 'libzip-1.9.2.tar.gz' -> '/nix/store/hc734ibn23s12wv7716jxw6hb0fyhs40-libzip-1.9.2.tar.gz.drv'
instantiated 'libzip-1.9.2' -> '/nix/store/g0wm055xm1f0n3l3gz5inr9qpaj4hzh2-libzip-1.9.2.drv'
instantiated 'php-zip-8.1.13' -> '/nix/store/0675ggxcycmrra5bmds41rbjrp7v381y-php-zip-8.1.13.drv'
instantiated 'php-zlib-8.1.13' -> '/nix/store/cnj2gwh5jzimh44p1hdd1ajbgqkyq2h5-php-zlib-8.1.13.drv'
instantiated 'php-extra-init-8.1.13.ini' -> '/nix/store/5skya4z35pjjpwdvdfxjijxn0h70764l-php-extra-init-8.1.13.ini.drv'
instantiated 'php-with-extensions-8.1.13' -> '/nix/store/7glwyrax3vmnbvpmmzaasyf13cc6wmv5-php-with-extensions-8.1.13.drv'
error: php74 has been dropped due to the lack of maintanence from upstream for future releases
(use '--show-trace' to show detailed location information)

(Sorry about the wall of text, replit doesn’t allow me to share more than one media file)
I pressed Ctrl-C in the middle because it wouldn’t go past the line above, and pressing that gave the rest of the output.
Now, this error keeps repeatedly printing in the console, and does not stop no matter what I do.


(See the scroll bar on the bottom right)
I cannot start my bot because of this.
I have typed exit 1 in the shell, restarted the website, pressed Ctrl-C everywhere, cleared the console.

TL;DR:

  1. How do you download opus in replit?
  2. PHP install failed, and error output keeps printing repeatedly in the console, causing me to not be able to run my discord bot.
  3. Console keeps showing loading Nix environment, but doesn’t do anything or stop showing this line.

Repl link:
https://replit.com/@SkullBlazer/Discord-Bot-Again

with youtube_dl.YoutubeDL(ydl_opts) as ydl:
	info = ydl.extract_info(query, download=False)
	url2 = info['webpage_url']
	print(url2)
	source = discord.FFmpegPCMAudio(url2)
	vc = ctx.voice_client
	vc.play(source)

This implies that something caused your replit.nix file to get messed up, please provide the contents of your replit.nix file.

{ pkgs }: {
  deps = [
    pkgs.php74
    pkgs.apacheHttpdPackages.php
    pkgs.apacheHttpdPackages.php
    pkgs.php74
    pkgs.ffmpeg.bin
    pkgs.python310Full
    pkgs.replitPackages.prybar-python310
    pkgs.replitPackages.stderred
  ];
  env = {
    PYTHON_LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [
      # Needed for pandas / numpy
      pkgs.stdenv.cc.cc.lib
      pkgs.zlib
      # Needed for pygame
      pkgs.glib
      # Needed for matplotlib
      pkgs.xorg.libX11
    ];
    PYTHONHOME = "${pkgs.python310Full}";
    PYTHONBIN = "${pkgs.python310Full}/bin/python3.10";
    LANG = "en_US.UTF-8";
    STDERREDBIN = "${pkgs.replitPackages.stderred}/bin/stderred";
    PRYBAR_PYTHON_BIN = "${pkgs.replitPackages.prybar-python310}/bin/prybar-python310";
  };
}

Should I delete the 4 dependencies on PHP?

Yeah, they shouldn’t be listed twice (each), and they’re causing crashes regardless.

1 Like

Ah thanks, that did solve the issue of the infinite errors.
Now, if I run my code, it just doesn’t give any output. Only after refreshing the tab, do I get this output:
image
Do you know what could’ve caused it, or how I can fix it?

Hm. That shouldn’t have happened. Technically, prybar isn’t required though, so unless it prevents you from running your program, you can safely ignore that.

I’m not sure if that is the cause of my code not running, but nonetheless, my code isn’t able to run.


It just gets stuck here until I refresh the page, which gives the error I mentioned above.

Hm. Try opening the .replit file, and removing the whole [interpreter] section from the file, then run kill 1 in the Shell tab.

1 Like

Whoa that worked, thank you so much!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.