ml-explore / mlx-examples

Examples in the MLX framework
MIT License
6.3k stars 898 forks source link

Make sure to import the correct "version" module when installing mlx_whisper and mlx_lm from local source code. #969

Closed walkoncross closed 2 months ago

walkoncross commented 3 months ago

Fix module conflicts when install mlx_whisper and mlx_lm from local source code.

Problem

When installing mlx_whisper from local source code by running: ''' cd whisper pip install -e . '''

I got an error as following: ''' Obtaining file:///Users/zhaoyafei/work/mlx-examples/whisper Preparing metadata (setup.py) ... error error: subprocess-exited-with-error

× python setup.py egg_info did not run successfully. │ exit code: 1 ╰─> [6 lines of output] Traceback (most recent call last): File "", line 2, in File "", line 34, in File "/Users/zhaoyafei/work/mlx-examples/whisper/setup.py", line 15, in from version import version ImportError: cannot import name 'version' from 'version' (/Users/zhaoyafei/work/opendr/opendr/version.py) [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed

× Encountered error while generating package metadata. ╰─> See above for output.

note: This is an issue with the package mentioned above, not pip. hint: See above for details. '''

The same error was encountered when installing the mlx_lm package from local source code.

Solution:

mlx-whisper

mlx-lm

awni commented 3 months ago

I'm not getting that error running pip install -e . in either subdirectory. And in fact the change you made would break other things (like building with python -m build so we should not do that.

Perhaps you need to upgrade pip? pip install -U pip. If that doesn't solve it.. please file an issue and we can help debug.

walkoncross commented 3 months ago

I'm not getting that error running pip install -e . in either subdirectory. And in fact the change you made would break other things (like building with python -m build so we should not do that.

Perhaps you need to upgrade pip? pip install -U pip. If that doesn't solve it.. please file an issue and we can help debug.

@awni

I got this error because I have installed a python package (i.e opendr) which exposes a module named "version.py".

I have tried "pip install -U pip." but it did not fix the error.

I have to manually fix the error everytime.

This PR is just to avoid other people encountering similar problems.

Please consider whether to close this PR.

awni commented 3 months ago

Gotcha! How about rename those files to _version.py?

walkoncross commented 3 months ago

Gotcha! How about rename those files to _version.py?

@awni As long as it can solve the problem, it's fine.

awni commented 3 months ago

Do you want to update this PR with that change?

walkoncross commented 3 months ago

Do you want to update this PR with that change?

@awni ok, I can do it.

walkoncross commented 3 months ago

Fix module conflicts when install mlx_whisper and mlx_lm from local source code.

Problem

When installing mlx_whisper from local source code by running: ''' cd whisper pip install -e . '''

I got an error as following: ''' Obtaining file:///Users/zhaoyafei/work/mlx-examples/whisper Preparing metadata (setup.py) ... error error: subprocess-exited-with-error

× python setup.py egg_info did not run successfully. │ exit code: 1 ╰─> [6 lines of output] Traceback (most recent call last): File "", line 2, in File "", line 34, in File "/Users/zhaoyafei/work/mlx-examples/whisper/setup.py", line 15, in from version import version ImportError: cannot import name 'version' from 'version' (/Users/zhaoyafei/work/opendr/opendr/version.py) [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed

× Encountered error while generating package metadata. ╰─> See above for output.

note: This is an issue with the package mentioned above, not pip. hint: See above for details. '''

The same error was encountered when installing the mlx_lm package from local source code.

Solution:

mlx-whisper

  • Rename whisper/mlx_whisper/version.py into whisper/mlx_whisper/_version.py
  • In whisper/setup.py, replace '''from version import version''' by '''from _version import version'''.

mlx-lm

  • Rename llms/mlx_lm/version.py into llms/mlx_lm/_version.py
  • In llms/setup.py, replace '''from version import version''' by '''from _version import version'''.

@awni This PR has been updated according to the method we discussed.