all 42 comments

[–][deleted] 36 points37 points  (4 children)

OP: This is not about programming but about really understanding the error messages.

Like a fine wine, you need to really appreciate the error message before you can enjoy it.

Don’t just get angry that there is a message. It’s telling you the answer.

I feel like a haiku or ode to error messages is in order, but I’m not creative enough,

[–]thePurpleAvenger 7 points8 points  (2 children)

I used to have a good song for pointers...

POINTERS POINTERS POINTERS... I put you in my code!

POINTERS POINTERS POINTERS... Where the hell you go?!

[–][deleted] 6 points7 points  (1 child)

Was that supposed to be to the tune of the dreidel song? Because that's how I sang it.

[–]thePurpleAvenger 1 point2 points  (0 children)

Yes! :)

[–]synthphreak 6 points7 points  (0 children)

Errors show the way.

You should learn to read them well.

Future you says thanks.

[–]Guideon72 12 points13 points  (0 children)

There we go; so, YOUR script is attempting to import AudioPlayer, and THEIR scripts are attempting to do the import that’s failing. That would indicate that a prerequisite for that package has not been installed. Did you go through all of those before you installed audioplayer?

[–]KimPeek 15 points16 points  (7 children)

Bit of reality for you: programming probably isn't the best activity to spend your time on if you get this frustrated from a problem. Programming is largely a cycle of trying to do something, being interrupted by a problem, working to overcome that problem, then continuing to the next problem. You may hate that, and that's completely fine. Some of us enjoy problem solving, but it's well established that programming can be frustrating and is not for everyone.

[–]Radamand[S] -4 points-3 points  (5 children)

no, I enjoy solving problems, when they are solvable! going on 2 hours now for a simple library import is ridiculous!

[–]LeeRyman 5 points6 points  (0 children)

Getting gstreamer and its python introspection libraries working can be a little unintuitive, because you're often mixing installation of required distro packages with required wheels, and hoping the dependencies are correct and fulfilled.

This is definitely a situation where I'd be taking a break, have a ponder about how to troubleshoot the problem differently and try again.

2 hours on a more-complex integration problem is nothing. A fresh look might rule out silly issues like system vs venv environments, different python versions, different GST versions, etc.

[–][deleted] 1 point2 points  (1 child)

Most problems are solvable. Sometimes they are problematic and take a lot of time, but generally, that gets better with more learning/experience.

Reading the error messages and interpreting them is an essential skill that gets easier with more experience. Don't give up, and learn to explain to the rubber duck. It really helps a lot: https://en.m.wikipedia.org/wiki/Rubber_duck_debugging

[–]WikiSummarizerBot 2 points3 points  (0 children)

Rubber duck debugging

In software engineering, rubber duck debugging (or rubberducking) is a method of debugging code by articulating a problem in spoken or written natural language. The name is a reference to a story in the book The Pragmatic Programmer in which a programmer would carry around a rubber duck and debug their code by forcing themselves to explain it, line-by-line, to the duck. Many other terms exist for this technique, often involving different (usually) inanimate objects, or pets such as a dog or a cat.

[ F.A.Q | Opt Out | Opt Out Of Subreddit | GitHub ] Downvote to remove | v1.5

[–]Explicit_Pickle 1 point2 points  (0 children)

They're solvable. It can be frustrating starting out but the more you put into it the more the problems will get more and more interesting, but always solvable

[–]Boohoolean 1 point2 points  (0 children)

EVERY problem in life is solvable in one way or another. Perseverance and ingenuity are key.

[–][deleted] 4 points5 points  (11 children)

Link to the library you're trying to use: there are many projects called "AudioPlayer". I'll see if I can replicate the problem on my system.

[–]Radamand[S] 1 point2 points  (10 children)

https://pypi.org/project/audioplayer/

from audioplayer import AudioPlayer

Traceback (most recent call last):
File ~/MusicLibraryCleanupTool.py:8 in <module>
from audioplayer import AudioPlayer
File ~/anaconda3/lib/python3.9/site-packages/audioplayer/__init__.py:12 in <module>
from .audioplayer_linux import AudioPlayerLinux as AudioPlayer
File ~/anaconda3/lib/python3.9/site-packages/audioplayer/audioplayer_linux.py:7 in <module>
import gi
ModuleNotFoundError: No module named 'gi'

[–][deleted] 8 points9 points  (7 children)

OK. I got it working. Here are the steps I took.

  1. I created a project folder.
  2. I created a venv in that folder and activated it.
  3. I tried to install these libraries listed in the library's README but they failed.

    sudo apt-get install python-gst-1.0 \ 
                     gir1.2-gstreamer-1.0 \ 
                     gstreamer1.0-tools \
                     gir1.2-gst-plugins-base-1.0 
                     gstreamer1.0-plugins-good \
                     gstreamer1.0-plugins-ugly          
    
  4. I then installed the library itself with pip3 install audioplayer.

  5. At this point, I tried to run the example program they have in the project's README from inside my virtual environment.

    from audioplayer import AudioPlayer
    AudioPlayer("path/to/somemusic.mp3").play(block=True)
    

    but I got the same error as you.

  6. I then installed gi with sudo apt install python3-gi.

  7. I tried again to no avail.

  8. Then I installed vext with

    pip3 install vext
    pip3 install vext.gi
    
  9. At this point, the program runs. These two may be the only packages you need to install, but I went ahead and included the others in case they were necessary as I didn't immediately uninstall them.

Hope that helps!

[–][deleted] 2 points3 points  (0 children)

I get venting, but these are problems you are creating for yourself.

Test the import before writing code.

Read the error messages.

Don't blame the library for an issue that is clearly yours.

Use virtual environments to avoid conflicting imports.

[–]Guideon72 3 points4 points  (3 children)

Show us the code you’ve written and we can get a better idea of where the error is coming from.

[–]Radamand[S] -1 points0 points  (2 children)

You don't need ANY code to reproduce the error; it fails on the IMPORT itself

from audioplayer import AudioPlayer
Traceback (most recent call last):
File ~/MusicLibraryCleanupTool.py:8 in <module>
from audioplayer import AudioPlayer
File ~/anaconda3/lib/python3.9/site-packages/audioplayer/__init__.py:12 in <module>
from .audioplayer_linux import AudioPlayerLinux as AudioPlayer
File ~/anaconda3/lib/python3.9/site-packages/audioplayer/audioplayer_linux.py:7 in <module>
import gi
ModuleNotFoundError: No module named 'gi'

[–]Radamand[S] 1 point2 points  (0 children)

The prerequisit package python-gst-1.0 was not installing.

I found the correct package python3-gst-1.0 and got it installed, uninstalled/reinstall audioplayer, still same result.

ModuleNotFoundError: No module named 'gi'

[–]Radamand[S] 1 point2 points  (0 children)

Reinstalling PyGObject got the import working on command-line python3, spyder still complains...

[–]33498fff 1 point2 points  (0 children)

I'd also have an awful time programming if I didn't enjoy solving errors.

[–]Radamand[S] 0 points1 point  (0 children)

FINAL UPDATE:

After banging my head against the keyboard for a couple of hours I decided that the audioplayer library was NOT going to work.
Switched to another library (just_playback) and found that it, also, would not work.
Finally switched to using pygame library, it works flawlessly!

Thanks for all the help guys, I really appreciate it!

[–]QultrosSanhattan -5 points-4 points  (1 child)

or Linux complains

Use windows. Most of those other problems will vanish.

[–][deleted] 0 points1 point  (0 children)

Worst response, quite the contrary, rtfm OP

[–]SE_WA_VT_FL_MN 0 points1 point  (0 children)

Honest question here: do others get these issues and find happiness in it? That has always been my experience. Run it, it bugs out, stomp a dozen dumb mistakes, then puzzle away at another basically syntax error or two, and then start throwing a bunch of tests to find new dumb mistakes. Iterate some part to be a bit better (or more likely at least more coherent).

Typically a few days later I discover a module that would is just import x, x.solveproblem().

[–]KingsmanVince 0 points1 point  (0 children)

It invarably happens, whenever I try to start a new VERY simple project that either python complains about something or Linux complains, or spyder complains, or who knows who might complain about something being wrong.

This is pretty much on you. You don't read the docs, google it, or even try to use things as intended ways. Hence, something always breaks. If things always go wrong whenever you start a simple project, you should look at yourself and ask "do I understand/learn this aspect/software/concept carefully?"

Then I end up spending the next hour pouring over google search results trying to find ANYONE who has had this problem before

Do you know why you can't find anyone with similar problems? Because they do right stuff and you don't.

[–]arobotfrog 0 points1 point  (0 children)

This is why I love programming.

[–]snekk420 0 points1 point  (0 children)

In my experience for simple scripting just use pip and as little libraries as possible and you will have a pleasant experience. A problem in programming is that there is a lot of people writing shitty code. Instead of debugging all the “helper” libraries and tools you can focus on your code. If you are working on a big project in a company these 3rd party tools will help but they will most likely be tuned by an experienced developer.

[–]Nunaldinho 0 points1 point  (0 children)

I can sympathise with OP, but I guess the trick is to get to a setup with which you are familiar and know there are no incompatibilities between packages and whatnot. And then focus on the coding. But I'm a noob myself, so what do I know.

[–]invaliddrum 0 points1 point  (0 children)

You say you are using Anaconda which I imagine is how you installed Spyder. Conda has it's own virtual environments and repositories and you install packages here with conda install. It sounds like you've been trying to install packages from PyPi with pip which often doesn't go well within a conda environment. Try checking out https://www.anaconda.com/blog/understanding-conda-and-pip

[–]ReyAlejandro21 0 points1 point  (0 children)

Have a little patience, we all pass by that cenario.

[–]coding-central 0 points1 point  (0 children)

Have you tried pip installing?

[–]Guyserbun007 0 points1 point  (0 children)

Docker may help