worldveil / dejavu

Audio fingerprinting and recognition in Python
MIT License
6.41k stars 1.43k forks source link

Error with Env PATH #86

Closed winos closed 9 years ago

winos commented 9 years ago

i have this issue when to run the audioRecognizer,¿ what do i do?

  string(92) "  File "/usr/local/apache2/htdocs/1.2/fingerprinting/pydub/__init__.py", line 1, in 
            <module>"
  [8]=>
  string(43) "    from .audio_segment import AudioSegment"
  [9]=>
  string(98) "  File "/usr/local/apache2/htdocs/1.2/fingerprinting/pydub/audio_segment.py", line 38, in 
                <module>"
  [10]=>
  string(31) "    class AudioSegment(object):"
  [11]=>
  string(102) "  File "/usr/local/apache2/htdocs/1.2/fingerprinting/pydub/audio_segment.py", line 49, in AudioSegment"
  [12]=>
  string(61) "    converter = get_encoder_name()  # either ffmpeg or avconv"
  [13]=>
  string(99) "  File "/usr/local/apache2/htdocs/1.2/fingerprinting/pydub/utils.py", line 112, in get_encoder_name"
  [14]=>
  string(23) "    if which("avconv"):"
  [15]=>
  string(88) "  File "/usr/local/apache2/htdocs/1.2/fingerprinting/pydub/utils.py", line 100, in which"
  [16]=>
  string(54) "    envdir_list = os.environ["PATH"].split(os.pathsep)"
  [17]=>
  string(64) "  File "/usr/lib/python2.7/UserDict.py", line 23, in __getitem__"
  [18]=>
  string(23) "    raise KeyError(key)"
  [19]=>
  string(16) "KeyError: 'PATH'"
worldveil commented 9 years ago

Well it is saying that your bash variable $PATH is not in your env.

I'm really not sure what would cause this - perhaps you are using some sort of bare-bones shell in cron script (or your shell isn't even bash).

At any rate, I can't generally debug this nor does it seem like an issue with the library. If something changes or you discover an issue with the library please do comment back again.

winos commented 9 years ago

Ok @worldveil , look up the problem is the setup of apache :(. in this document explain that happens but that does not working for me.

check it from stackoverflow check it from apache doc official

winos commented 9 years ago

@worldveil I tried this and work for me:

Solution 1

# show the variable environment with this:
% echo $PATH

# show:
% /usr/local/bin:/usr/bin:/bin:/usr/games:/opt/gradle/gradle-2.3/bin:/opt/gradle/bin:

Next modify the file "fingerprinting/pydub/utils.py":

# After that your perfom the imports add this line:

os.environ["PATH"] = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:"

Solution 2

you should create a virtual environment to your project: checkout: how to create a VE