6

I can't get the ffprobe package to work in Python 3.6. I installed it using pip, but when I type import ffprobe it says

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python\Python36\lib\site-packages\ffprobe\__init__.py", line 1, in <module>
  from ffprobe import FFProbe
ImportError: cannot import name 'FFProbe'
  • The __init__.py file contains just the single line from ffprobe import FFProbe.

  • sys.path includes 'C:\Python\Python36\lib\site-packages', which is where the ffprobe directory is located.

  • Installing and importing the package works in Python 2.7 with no problems. But I would like to use it in Python 3, even if that means making manual changes to the .py files. (There is no documentation that says the package only works in Python 2.)

Can anyone help?

user1310503
  • 557
  • 5
  • 11
  • 1
    That import doesn't look right... It should work if you change it to `from .ffprobe import FFProbe`. – Aran-Fey May 28 '17 at 13:45
  • I changed \_\_init__.py to that, and now the import works, but there are other errors that show the package is designed for Python 2 only. Anyway thank you for your answer. Could you tell me why `from ffprobe import FFProbe` works in Python 2 and why the dot is needed in Python 3? – user1310503 May 28 '17 at 16:22
  • I'm not sure about that either; python 2 import mechanics aren't something I'm overly familiar with. Who knows, maybe python 2 imports a different version of the module where the import is correct? – Aran-Fey May 28 '17 at 17:14
  • OK, thanks. But why did you guess that it would work with `.ffprobe` instead of `ffprobe`? – user1310503 May 29 '17 at 10:17
  • 1
    `import module_name` imports a module from python's library, whereas `import .module_name` imports a (sub-)module from the current module's directory. With `from ffprobe import`, the ffprobe module was importing itself, which makes no sense. With `from .ffprobe import`, it imports from the `ffprobe.py` file that's in the same directory as the `__init__.py`. – Aran-Fey May 29 '17 at 10:28

2 Answers2

8

Use this ffprobe package instead for Python3. Works for me: pip install ffprobe-python

I Like
  • 1,711
  • 2
  • 27
  • 52
2

The solution is that the ffprobe package only works with Python 2.

In Python 3 the import statement would need to be from .ffprobe ..., but just changing that is not sufficient as there are other lines that only work in Python 2 as well.

Thanks to Rawing.

user1310503
  • 557
  • 5
  • 11