marcelotduarte / cx_Freeze

cx_Freeze creates standalone executables from Python scripts, with the same performance, is cross-platform and should work on any platform that Python itself works on.
https://marcelotduarte.github.io/cx_Freeze/
Other
1.33k stars 217 forks source link

Error message: no base named 'console' ('console-cpython-311-win_amd64') for python 3.11 #2392

Closed jpotter0 closed 4 months ago

jpotter0 commented 4 months ago

I am trying to build an executable from my python code. I created a setup.py file. This file is the same as one that worked previously under version 6.15.16 except I added two exclusions for matplotlib and pyvista. My code has no plots and runs correctly in PyCharm except for warnings about matplotlib and pyvista, which i don't want my executable users to see.

from cx_Freeze import setup, Executable

# Dependencies are automatically detected, but some modules need manual configuration
build_exe_options = {"packages": ["os"], "excludes": ["tkinter","pyvista","matplotlib"],"include_files": [
        ("C:\\Users\\jpotter\\AppData\\Local\\Programs\\Python\\Python311\\python3.dll", "python3.dll"), 
        ("C:\\Users\\jpotter\\AppData\\Local\\Programs\\Python\\Python311\\python311.dll", "python311.dll")]}

setup(
    name = "CoilCalc",
    version = "0.3",
    description = "My CoilCalc application!",
    options = {"build_exe": build_exe_options},
    executables = [Executable("CoilCalc.py")]
)

I have tried various ploys such as setting base to "console"and "None". but the above script should work since "console" is the default according to the documentation.

I have used pip to install v 7.0. I downloaded the source from PiPy and recompiled it. Then I downloaded the source from the Git cx-freeze repository. That got my hopes ups since it was version 7.1.0. But all yield exactly the same error: (venv) c:\Users\jpotter\PycharmProjects\pythonProject5>python setup.py build

Traceback (most recent call last):
  File "c:\Users\jpotter\PycharmProjects\pythonProject5\setup.py", line 13, in <module>
    executables = [Executable("CoilCalc.py")]
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Dev\cx_Freeze\venv\Lib\site-packages\cx_freeze-7.1.0.dev0-py3.11-win-amd64.egg\cx_Freeze\executable.py", line 47, in __init__
    self.base = base
    ^^^^^^^^^
  File "c:\Dev\cx_Freeze\venv\Lib\site-packages\cx_freeze-7.1.0.dev0-py3.11-win-amd64.egg\cx_Freeze\executable.py", line 87, in base
    raise OptionError(msg)
cx_Freeze.exception.OptionError: no base named 'console' ('console-cpython-311-win_amd64')

After all I have been through the conclusion I have come to is that base="console" is missing from the installation, The base directory contains:

 Directory of c:\Users\jpotter\PycharmProjects\pythonProject5\venv\Lib\site-packages\cx_freeze\bases

05/12/2024  02:14 AM    <DIR>          .
05/12/2024  02:14 AM    <DIR>          ..
05/12/2024  02:13 AM            17,920 Win32GUI-cpython-311-win_amd64.exe
05/12/2024  02:13 AM            26,624 Win32Service-cpython-311-win_amd64.exe
05/12/2024  02:13 AM                68 __init__.py
05/12/2024  02:14 AM    <DIR>          __pycache__
               3 File(s)         44,612 bytes
               3 Dir(s)  1,211,067,854,848 bytes free

I am at a loss about how to solve this problem. Suggestions are greatly appreciated.

Jim

jpotter0 commented 4 months ago

I am running CPython v3.11 on Windows 11 with current updates on an i913900 CPU.. My program is in a virtual environment.

marcelotduarte commented 4 months ago

There must have been an error when installing cx_Freeze. In the bases folder you must have the console file. In fact, I downloaded the file directly from Pypi and saw that it is correct. I suggest uninstalling and force installing. Also check that there is no antivirus interfering with the installation. pip uninstall -y cx_Freeze pip install cx_Freeze --no-cache --force

In case you tried to download the sources, you have to have MS VC to compile, otherwise it will go wrong,

jpotter0 commented 4 months ago

Thanks for the reply and suggestions. I will give them a try. I'll let you know whether or not I am successful

I previously successfully installed and used v 6.15.16, but reverting to it didn't fix the problem.

I did follow the instructions for downloading the compiler.

Regards,

Jim

On May 12, 2024 4:41:44 PM MDT, Marcelo Duarte @.***> wrote:

There must have been an error when installing cx_Freeze. In the bases folder you must have the console file. In fact, I downloaded the file directly from Pypi and saw that it is correct. I suggest uninstalling and force installing. Also check that there is no antivirus interfering with the installation. pip uninstall -y cx_Freeze pip install cx_Freeze --no-cache --force

In case you tried to download the sources, you have to have MS VC to compile, otherwise it will go wrong,

-- Reply to this email directly or view it on GitHub: https://github.com/marcelotduarte/cx_Freeze/issues/2392#issuecomment-2106397484 You are receiving this because you authored the thread.

Message ID: @.> -- James M. Potter PhD, President JP Accelerator Works, Inc. 2245 47th Street Los Alamos, NM 87544 TEL: (505) 690-8701 EMAIL: @.

Sent from my Android device with K-9 Mail.

marcelotduarte commented 4 months ago

I did follow the instructions for downloading the compiler.

I'm not recommending this, I just said that you need the C compiler to compile from sources. I really recommend trying to use pip again, cleaning the previous installation, and if possible even creating a new venv. Another possibility is to use the development version, which I should release in a few days: pip install --force --no-cache --pre --extra-index-url https://marcelotduarte.github.io/packages/ cx_Freeze

jpotter0 commented 4 months ago

For some reason, I get a 'permission denied' error when I try to reinstall cx_Freeze, even though I opened the Command Line Interpreter as an administrator. I have been having this problem all along. A workaround has been to reboot my computer. This is probably a Windows 11 problem. In any case, I got the .exe file created. I ran it, and it works perfectly.

I just noticed that when I ran the executible, I got a notice that pyvista and matplotlib are required 'to run some functionalities'. Both pyvista and matplotlib were pip installed by the executable, in spite of being on the exclusion list in setup.py. I guess I'll remove the two exclusions from the setup.py file. I know that there are no plots on my program, and my program works perfectly in PyCharm without importing the files. I don't know what makes this requirement. I also get a message that CPython is required, which is odd since the program is written in CPython. Should I put CPython in the includes list?

Thanks,

Jim

On May 12, 2024 4:41:44 PM MDT, Marcelo Duarte @.***> wrote:

There must have been an error when installing cx_Freeze. In the bases folder you must have the console file. In fact, I downloaded the file directly from Pypi and saw that it is correct. I suggest uninstalling and force installing. Also check that there is no antivirus interfering with the installation. pip uninstall -y cx_Freeze pip install cx_Freeze --no-cache --force

In case you tried to download the sources, you have to have MS VC to compile, otherwise it will go wrong,

-- Reply to this email directly or view it on GitHub: https://github.com/marcelotduarte/cx_Freeze/issues/2392#issuecomment-2106397484 You are receiving this because you authored the thread.

Message ID: @.> -- James M. Potter PhD, President JP Accelerator Works, Inc. 2245 47th Street Los Alamos, NM 87544 TEL: (505) 690-8701 EMAIL: @.

Sent from my Android device with K-9 Mail.

marcelotduarte commented 4 months ago

I get a 'permission denied' error when I try to reinstall cx_Freeze, even though I opened the Command Line Interpreter as an administrator. I have been having this problem all along. A workaround has been to reboot my computer. This is probably a Windows 11 problem.

I think it could be the antivirus. See this recent case: #2383

I guess I'll remove the two exclusions from the setup.py file

If it works, and you do not need them, you can use them in 'excludes'.

I also get a message that CPython is required, which is odd since the program is written in CPython. Should I put CPython in the includes list?

No. But, I vote to you remove .dll in "include_files". cx_Freeze detects the required dependencies.

Are you using Python from the Windows Store?

jpotter0 commented 4 months ago

I did a pip install. I'm not sure where it came from.

I'm still stuggling with the "no base named 'console'" issue. This morning, I modified my setup.py to remove pyvista and matplotlib from the excludes. I don't recall 100% exactly what I did. Since cx_Freeze was successfully installed yesterday, I didn't do anything to mess with it. I ran something that got me the permission denied error, I think it was python setup.py build, but I could be remembering wrong. I turned off bitdefender for 15 minutes. Then I got the no base named 'console' error. I rebooted and reran python setup.py build and still got theno console error.

I'm trying to find the right sequence of operations to get this to work. I think my temporary turnoff of bitdefender may have expired. Now, I am going to try it again from a reboot. I didn't have this problem when I used cx_Freeze 6.15.16 earlier last week. One difference is that I moved my souce code into a virtual environment. I also moved setup into the project directory.

I will start over with a reboot and keep better track of my steps and results.

I'll let you know how it goes after my next attempt.

Jim

On May 13, 2024 12:28:13 AM MDT, Marcelo Duarte @.***> wrote:

I get a 'permission denied' error when I try to reinstall cx_Freeze, even though I opened the Command Line Interpreter as an administrator. I have been having this problem all along. A workaround has been to reboot my computer. This is probably a Windows 11 problem.

I think it could be the antivirus. See this recent case: #2383

I guess I'll remove the two exclusions from the setup.py file

If it works, and you do not need them, you can use them in 'excludes'.

I also get a message that CPython is required, which is odd since the program is written in CPython. Should I put CPython in the includes list?

No. But, I vote to you remove .dll in "include_files". cx_Freeze detects the required dependencies.

Are you using Python from the Windows Store?

-- Reply to this email directly or view it on GitHub: https://github.com/marcelotduarte/cx_Freeze/issues/2392#issuecomment-2106749813 You are receiving this because you authored the thread.

Message ID: @.> -- James M. Potter PhD, President JP Accelerator Works, Inc. 2245 47th Street Los Alamos, NM 87544 TEL: (505) 690-8701 EMAIL: @.

Sent from my Android device with K-9 Mail.

jpotter0 commented 4 months ago

The only thing that seems to work is to uninstall cx_Freeze and reinstall it per the directions in your earlier email. Then, I can create the executable with no problem.

I will try to repeat creating the executable and see what happens.

Jim

On May 13, 2024 6:46:30 AM MDT, Jim Potter @.***> wrote:

I did a pip install. I'm not sure where it came from.

I'm still stuggling with the "no base named 'console'" issue. This morning, I modified my setup.py to remove pyvista and matplotlib from the excludes. I don't recall 100% exactly what I did. Since cx_Freeze was successfully installed yesterday, I didn't do anything to mess with it. I ran something that got me the permission denied error, I think it was python setup.py build, but I could be remembering wrong. I turned off bitdefender for 15 minutes. Then I got the no base named 'console' error. I rebooted and reran python setup.py build and still got theno console error.

I'm trying to find the right sequence of operations to get this to work. I think my temporary turnoff of bitdefender may have expired. Now, I am going to try it again from a reboot. I didn't have this problem when I used cx_Freeze 6.15.16 earlier last week. One difference is that I moved my souce code into a virtual environment. I also moved setup into the project directory.

I will start over with a reboot and keep better track of my steps and results.

I'll let you know how it goes after my next attempt.

Jim

On May 13, 2024 12:28:13 AM MDT, Marcelo Duarte @.***> wrote:

I get a 'permission denied' error when I try to reinstall cx_Freeze, even though I opened the Command Line Interpreter as an administrator. I have been having this problem all along. A workaround has been to reboot my computer. This is probably a Windows 11 problem.

I think it could be the antivirus. See this recent case: #2383

I guess I'll remove the two exclusions from the setup.py file

If it works, and you do not need them, you can use them in 'excludes'.

I also get a message that CPython is required, which is odd since the program is written in CPython. Should I put CPython in the includes list?

No. But, I vote to you remove .dll in "include_files". cx_Freeze detects the required dependencies.

Are you using Python from the Windows Store?

-- Reply to this email directly or view it on GitHub: https://github.com/marcelotduarte/cx_Freeze/issues/2392#issuecomment-2106749813 You are receiving this because you authored the thread.

Message ID: @.> -- James M. Potter PhD, President JP Accelerator Works, Inc. 2245 47th Street Los Alamos, NM 87544 TEL: (505) 690-8701 EMAIL: @.

Sent from my Android device with K-9 Mail. -- James M. Potter PhD, President JP Accelerator Works, Inc. 2245 47th Street Los Alamos, NM 87544 TEL: (505) 690-8701 EMAIL: @.***

Sent from my Android device with K-9 Mail.

jpotter0 commented 4 months ago

The problem originates in Bitdefender. It thinks there is a problem with the bases\console file. I haven't succeeded in getting Bitdefender to allow it. If I am able to allow it, it is directory specific, so it may be that the solution for now is to disable Bitdefender temporarily.

On May 13, 2024 9:38:09 AM MDT, Jim Potter @.***> wrote:

The only thing that seems to work is to uninstall cx_Freeze and reinstall it per the directions in your earlier email. Then, I can create the executable with no problem.

I will try to repeat creating the executable and see what happens.

Jim

On May 13, 2024 6:46:30 AM MDT, Jim Potter @.***> wrote:

I did a pip install. I'm not sure where it came from.

I'm still stuggling with the "no base named 'console'" issue. This morning, I modified my setup.py to remove pyvista and matplotlib from the excludes. I don't recall 100% exactly what I did. Since cx_Freeze was successfully installed yesterday, I didn't do anything to mess with it. I ran something that got me the permission denied error, I think it was python setup.py build, but I could be remembering wrong. I turned off bitdefender for 15 minutes. Then I got the no base named 'console' error. I rebooted and reran python setup.py build and still got theno console error.

I'm trying to find the right sequence of operations to get this to work. I think my temporary turnoff of bitdefender may have expired. Now, I am going to try it again from a reboot. I didn't have this problem when I used cx_Freeze 6.15.16 earlier last week. One difference is that I moved my souce code into a virtual environment. I also moved setup into the project directory.

I will start over with a reboot and keep better track of my steps and results.

I'll let you know how it goes after my next attempt.

Jim

On May 13, 2024 12:28:13 AM MDT, Marcelo Duarte @.***> wrote:

I get a 'permission denied' error when I try to reinstall cx_Freeze, even though I opened the Command Line Interpreter as an administrator. I have been having this problem all along. A workaround has been to reboot my computer. This is probably a Windows 11 problem.

I think it could be the antivirus. See this recent case: #2383

I guess I'll remove the two exclusions from the setup.py file

If it works, and you do not need them, you can use them in 'excludes'.

I also get a message that CPython is required, which is odd since the program is written in CPython. Should I put CPython in the includes list?

No. But, I vote to you remove .dll in "include_files". cx_Freeze detects the required dependencies.

Are you using Python from the Windows Store?

-- Reply to this email directly or view it on GitHub: https://github.com/marcelotduarte/cx_Freeze/issues/2392#issuecomment-2106749813 You are receiving this because you authored the thread.

Message ID: @.> -- James M. Potter PhD, President JP Accelerator Works, Inc. 2245 47th Street Los Alamos, NM 87544 TEL: (505) 690-8701 EMAIL: @.

Sent from my Android device with K-9 Mail.

-- James M. Potter PhD, President JP Accelerator Works, Inc. 2245 47th Street Los Alamos, NM 87544 TEL: (505) 690-8701 EMAIL: @.***

Sent from my Android device with K-9 Mail.

jpotter0 commented 4 months ago

Bitdefender claims to have found a virus in the bases\console file. It has identified it as Gen:Variant.Tedy579949. I have had experience with virus protection programming programs overreacting to innocuous files. However, my program will have a user for the exe file. I can't risk sending an infected program to him. I will put some effort into finding out if the problem is real. How do I get a guaranteed clean copy of bases\console-cpython-311-win_amd64.exe?

marcelotduarte commented 4 months ago

The process is automatic via CI: https://github.com/marcelotduarte/cx_Freeze/actions/runs/8771749472/job/24070083583

Another option is building it. You need MS VC compiler.

jpotter0 commented 4 months ago

I followed your instructions for getting the files from a trusted source. It now works fine. I checked my exe file with Bitdefender and it does not find a virus. Thanks for your help!

marcelotduarte commented 4 months ago

Are you saying that using pip, Bitdefender reported it as a virus and you directly downloaded the wheel from github, you had no problems?

jpotter0 commented 4 months ago

Wherever it came from per your instructions to the other guy who is having the same problem. I have a 1 hour conference call coming up on the hour (1 PM MDT).

jpotter0 commented 4 months ago

When I checked the executable with Bit defender it showed that the file was clean. The versions I installed with pip install with no special instructions about the source appear to be infected.

jpotter0 commented 4 months ago

That's correct. Here's the command I used for a successful installation:

pip install cx_freeze --upgrade --trusted-host files.pythonhosted.org --trusted-host pypi.org --no-cache --force

I thik I left out --upgrade since it was a fresh install.

Jim

On May 14, 2024 12:50:18 PM MDT, Marcelo Duarte @.***> wrote:

Are you saying that using pip, Bitdefender reported it as a virus and you directly downloaded the wheel from github, you had no problems?

-- Reply to this email directly or view it on GitHub: https://github.com/marcelotduarte/cx_Freeze/issues/2392#issuecomment-2110914758 You are receiving this because you authored the thread.

Message ID: @.> -- James M. Potter PhD, President JP Accelerator Works, Inc. 2245 47th Street Los Alamos, NM 87544 TEL: (505) 690-8701 EMAIL: @.

Sent from my Android device with K-9 Mail.

jpotter0 commented 4 months ago

I was able to create an executable, but when I move the program and lib directory and two dlls related to CPython 3.11 I get this error message:

PyAEDT ERROR: ** PyAEDT ERROR: File "C:\Users\jpotter\AppData\Local\Programs\Python\Python311\Lib\site-packages\cx_Freeze\initscripts__startup.py", line 138, in run PyAEDT ERROR: File "C:\Users\jpotter\AppData\Local\Programs\Python\Python311\Lib\site-packages\cx_Freeze\initscripts\console.py", line 17, in run PyAEDT ERROR: File "CoilCalc.py", line 776, in PyAEDT ERROR: File "CoilCalc.py", line 374, in create_resonator PyAEDT ERROR: File "C:\Users\jpotter\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyaedt\generic\general_methods.py", line 221, in wrapper PyAEDT ERROR: File "C:\Users\jpotter\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyaedt\generic\general_methods.py", line 204, in wrapper PyAEDT ERROR: File "C:\Users\jpotter\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyaedt\modeler\cad\Primitives.py", line 3371, in subtract PyAEDT ERROR: File "C:\Users\jpotter\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyaedt\generic\grpc_plugin.py", line 133, in DynamicFunc PyAEDT ERROR: File "C:\Users\jpotter\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyaedt\generic\grpc_plugin.py", line 124, in Invoke__ PyA

You said the cx_Freeze would find the files it needed so T dropped python3dll and python311.dll from the includes.The error shows that it's looking for the dlls on the path in the originating computer where I created the exe file. I would guess that I need to put the paths to the two dlls back in the include list in setup,py, or is there some other explanation?

Regards,

Jim

At 12:50 PM 5/14/2024, you wrote:

Are you saying that using pip, Bitdefender reported it as a virus and you directly downloaded the wheel from github, you had no problems?

­ Reply to this email directly, https://github.com/marcelotduarte/cx_Freeze/issues/2392#issuecomment-2110914758view it on GitHub, or https://github.com/notifications/unsubscribe-auth/AKX7QMCNHFI2MRXVG4OAWYLZCJMGVAVCNFSM6AAAAABHSXNEDWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMJQHEYTINZVHAunsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

James M. Potter, PhD, President JP Accelerator Works, Inc. 2245 47th Street Los Alamos, NM 87544

TEL: 505-690-8701

marcelotduarte commented 4 months ago

The python dlls are automatically copied. The dependencies for some modules and packages, sometimes we need to copy them or make a hook to copy them. Do you a sample with the module pyaedt? I'll make a hook for it.

jpotter0 commented 4 months ago

I'm not sure what you mean. I am restoring my setup file to its original configuration. I thought I did, but I made an error in the way I listed the include files. I will retry that. I will revert to my original file, which didn't exclude pyvista and matplotlib:

from cx_Freeze import setup, Executable

Dependencies are automatically detected, but some modules need manual configuration

build_exe_options = {"packages": ["os"], "excludes": ["tkinter"],"include_files": [ ("C:\Users\jpotter\AppData\Local\Programs\Python\Python311\python3.dll", "python3.dll"), ("C:\Users\jpotter\AppData\Local\Programs\Python\Python311\python311.dll", "python311.dll")]}

setup( name = "CoilCalc", version = "1.0.3", description = "My CoilCalc application!", options = {"build_exe": build_exe_options}, executables = [Executable("CoilCalc.py")] )

marcelotduarte commented 4 months ago

A small code to demostrate the use or to reproduce the error. For instance, to demonstrate the use of cx_Freeze with matplotlib, we have https://github.com/marcelotduarte/cx_Freeze/tree/main/samples/matplotlib_tk, so if you have a small sample to reproduce your case using pyaedt...

jpotter0 commented 4 months ago

Marcelo,

Just to give you an update, I am able to create executable files with cx_freeze on both of my computers. The executables run without errors. I modified my code so it will run from any directory, and the subdirectories containing input and ouput files for many calculations can also be in any directory, with the default being the directory from which the executable is run. I am not a professional programmer. I am happy that I can create a sophisticated application, thanks to you and all the others who have created libraries of Python applications.

Thank you for your help. I really appreciate you taking the time to assist me.

Best regards,

Jim

On May 14, 2024 2:37:27 PM MDT, Jim Potter @.***> wrote:

That's correct. Here's the command I used for a successful installation:

pip install cx_freeze --upgrade --trusted-host files.pythonhosted.org --trusted-host pypi.org --no-cache --force

I thik I left out --upgrade since it was a fresh install.

Jim

On May 14, 2024 12:50:18 PM MDT, Marcelo Duarte @.***> wrote:

Are you saying that using pip, Bitdefender reported it as a virus and you directly downloaded the wheel from github, you had no problems?

-- Reply to this email directly or view it on GitHub: https://github.com/marcelotduarte/cx_Freeze/issues/2392#issuecomment-2110914758 You are receiving this because you authored the thread.

Message ID: @.> -- James M. Potter PhD, President JP Accelerator Works, Inc. 2245 47th Street Los Alamos, NM 87544 TEL: (505) 690-8701 EMAIL: @.

Sent from my Android device with K-9 Mail. -- James M. Potter PhD, President JP Accelerator Works, Inc. 2245 47th Street Los Alamos, NM 87544 TEL: (505) 690-8701 EMAIL: @.***

Sent from my Android device with K-9 Mail.

marcelotduarte commented 4 months ago

You're welcome. I'm glad you managed to resolve it. I'll close the issue then.

marcelotduarte commented 4 months ago

Release 7.1.0 is out! Documentation

jpotter0 commented 4 months ago

Marcel, 1 Thanks for the update. I'll check it out. Everything has been going smoothly on my end. The user had problems. I discovered that the zip file I sent had been incorrectly unpacked by whatever file extractor was used. The user sent me a copy of the entire directory they were using. The library directory was incomplete. Also, the share directory was missing. When I fixed that using the files I sent, everything works correctly. the user needs to fix the problem on their end.

I'm thinking that I need to calculate a checksum so the user can verify that all the files transferred and unpacked correctly.

Jim

On May 26, 2024 12:19:49 AM MDT, Marcelo Duarte @.***> wrote:

Release 7.1.0 is out! Documentation

-- Reply to this email directly or view it on GitHub: https://github.com/marcelotduarte/cx_Freeze/issues/2392#issuecomment-2132082634 You are receiving this because you authored the thread.

Message ID: @.***> James M. Potter, PhD, President JP Accelerator Works, Inc. 2245 47th Street Los Alamos, NM 87544

TEL: +1 505-690-8701 email: @.***

marcelotduarte commented 4 months ago

Or, you can use bdist_msi. There are examples in the samples directory.