Home > other >  With the resource file Python package
With the resource file Python package

Time:10-21

Wrote a Python small programs, relying on a local music files, could you tell me how to guarantee after packaged into exe program still can find the music file, and play, to run on other computers

CodePudding user response:

 
The import sys
The from OS import join abspath, dirname

The root=dirname (abspath (sys. Argv [0]))
The file=join (root, 'XXX. Mp3)


CodePudding user response:

The
reference at the 1st floor response:
 
The import sys
The from OS import join abspath, dirname

The root=dirname (abspath (sys. Argv [0]))
The file=join (root, 'XXX. Mp3)

Use pyinstaller packaging, modify datas in the generated spec file=[(' oraociei11. DLL ', '. '), ()], then re-run pyinstaller -f XXX. The spec is ok

CodePudding user response:

0 f quoted Lee - xd reply:
write a Python small programs, relying on a local music files, could you tell me how to guarantee after packaged into exe program still can find the music file, and play, to run on the other computer

Use pyinstaller packaging, modify datas in the generated spec file=[(' oraociei11. DLL ', '. '), ()], then re-run pyinstaller -f XXX. The spec is ok

CodePudding user response:

The methods available to reply

CodePudding user response:

This is available?

CodePudding user response:

What is this oraociei. DLL

CodePudding user response:

Write a relative path, and maintain a relative path is changeless,
  • Related