0

this python program saves YouTube video converts it to mp3 and deletes the video. it works perfect on my pc, but when i make of it an exe file and send it to my friend, it doesn't work on his pc it says 'py' is not recognized as an internal or external command

is there a way i can fix it without changing the command itself, because it works perfectly except that issue

import os 

link_url = input("Enter url: ")
os.system('cmd /c "py -m youtube_dl --restrict-filenames --ignore-errors -x --audio-format mp3 %s"' %link_url)

input("Pres anything to exit: ")
Charles Duffy
  • 280,126
  • 43
  • 390
  • 441
osylyk
  • 1
  • 4
    This code is only expected to work for someone who has a Python interpreter installed. Just because you use `py2exe` (or `pyinstaller` or `cx_Freeze` or so forth), that doesn't mean that the code can suddenly call an *external* Python interpreter successfully; it only means the executable will have an *internal* Python interpreter embedded. That internal Python interpreter will only be bundled with dependencies that it `import`s; things you use indirectly like this won't be detected as requirements. – Charles Duffy Feb 11 '20 at 00:13
  • 1
    ...so, you do in fact need to change the code. Make it `import youtube_dl`, ditch the use of `os.system()`, and py2exe (or pyinstaller or whatever you're doing) will then bundle the `youtube_dl` module in your code. – Charles Duffy Feb 11 '20 at 00:14
  • 1
    Curious, why not tell your friend to use one of the numerous free online youtube-mp3 converters? – Hymns For Disco Feb 11 '20 at 00:19

1 Answers1

-1

If you are sure that python is installed on his system, then try using the command python instead of py instead.

Rein F
  • 320
  • 3
  • 9
  • 1
    `py` is the standard multi-version entry point to Python on Windows machines. If it's not unavailable on Windows, `python` is not likely to work either (or at least, not likely to be a *native Windows* Python build). – Charles Duffy Feb 11 '20 at 00:33