Search code examples
pythonmultiprocessingpyinstallergeventauto-py-to-exe

Using Auto-py-to-exe with MULTIPROCESSING lib: UndefinedEnvironmentName: 'extra' does not exist in evaluation environment


I am trying to create an .exe of my python application that I run from the server.py script. I am using Auto-py-to-exe in one directory mode which gives me the following command:

pyinstaller --noconfirm --onedir --console --icon "path" --name "name" --add-data "path" --add-data "path" --add-data "path" --hidden-import "openpyxl.cell._writer " --exclude-module "gevent server.py"  "C:/Users/140476/Documents/57956_EXE_ANALISIS_DATO_TALADRADO/server.py"

Those are my versions:

6067924 INFO: PyInstaller: 6.0.0
6067938 INFO: Python: 3.9.13 (conda)
6067956 INFO: Platform: Windows-10-10.0.19045-SP0
Running auto-py-to-exe v2.40.0

I receive the following error:

6258721 INFO: Loading module hook 'hook-gevent.py' from 
  File "C:\ProgramData\Anaconda3\lib\site-packages\packaging\markers.py", line 215, in _get_env
    raise UndefinedEnvironmentName(
packaging.markers.UndefinedEnvironmentName: 'extra' does not exist in evaluation environment.

Project output will not be moved to output folder
Complete.

Previously, I could make the .exe in my python project. Now I have added with pysimplegui a file explorer that uses the Multiprocessing library. Therefore, it makes me think that the failure could be related to this library. When I run it from console it works perfectly.

Attached are some parts of my code:

if __name__ == '__main__':
   if sys.platform.startswith('win'):
                # On Windows calling this function is necessary.
       freeze_support()
def interact_callbacks(self):
    @callback(
        Output('add-automatically-button', 'children'),
        Input('add-automatically-button', 'n_clicks')
    )
    def update_output(n_clicks):
        freeze_support()
        if n_clicks is not None:
            print('before process')
            p = Process(target=startInteraction)
            p.start()
            return 'Clicked!'
        else:
            return 'Add automatically'

Any kind of help is welcome, as I have no idea how to deal with this problem. Thank you very much in advance.


Solution

  • I had the same error message using PyInstaller on Linux, but I could imagine the cause in your case could also be the use of virtual Anaconda environments. What solved the issue in the end for me, was to install PyInstaller via conda instead of pip within the virtual environment (as also mentioned in a similar case here). As Auto-py-to-exe is built on PyInstaller it might also help to try

    conda install PyInstaller
    

    or, if it exists, a conda package of Auto-py-to-exe. However, this is just a guess, I haven't tried this on Windows.