Python Forum

Full Version: Determing packages needed by a script: Creating a Miniconda environment
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi
I have been given a bunch of python scripts, and want to create a Miniconda environment which contains all needed packages for the successful execution of those scripts.
The idea is to finally use Pyinstaller to create a self executable application with all required packages.
How do i figure out all the packages / modules needed by the scripts?
Based on that , i will create an environment in Miniconda with the required packages.

Thanks for any help / pointers

Best Regards
Ani
That is very broad question
(Jan-27-2020, 06:21 AM)ashevade Wrote: [ -> ]I have been given a bunch of python scripts
Normally whoever wrote the scripts should provide a documentation (incl. installation instructions and required third party packages to be installed in advance). Possibly there could be requirements.txt file that can be used to install third party-packages.
Possibly if there is setup script there should be required packages listed in it too (and installed when you run the setup).

If the scripts are currently running on your/some system you can use pip to list the installed packages/export the installed packages in requirements.txt (note that there might be installed packages that are not used).

There is modulefinder.

Of course you can visually examine/search all the source code and find the imports. If the imports are not listed at the top of each module it could be tedious job.

You can run the scripts and see what error they will throw (note that that require to run/test all the code). But if the author didn't bother to document properly how you can be sure it's been tested properly anyway?