Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: gen_id() takes 2 positional arguments but 3 were given #1184

Closed
Dennis-Asamoah opened this issue Jul 30, 2021 · 17 comments · Fixed by #1248
Closed

TypeError: gen_id() takes 2 positional arguments but 3 were given #1184

Dennis-Asamoah opened this issue Jul 30, 2021 · 17 comments · Fixed by #1248

Comments

@Dennis-Asamoah
Copy link

Dennis-Asamoah commented Jul 30, 2021

Describe the bug
the command "python setup.py bdist_msi" gives this error "TypeError: gen_id() takes 2 positional arguments but 3 were given". However when i use python setup.py build it builds successfully

To Reproduce

in the setup.py
#########################################################

import sys
from cx_Freeze import setup, Executable

base = None
if sys.platform == "win32":
    base = "Win32GUI"

build_exe={"packages":["PySide2","numpy","cv2","cryptography","psutil"],
"include_files":["saved_videos/","be.ico","settings.png","persist1.pickle","coco.names","nn.txt","froz.txt","eng.txt"]
}

executables = [
    Executable("main.py", base=base,icon="be.ico",shortcutDir="Desktop")
]

setup(
    name="Be",
    version="0.2",
    description="Sample cx_Freeze PySide2 script",
    options={"build_exe":build_exe},
    executables=executables
)

############################################
and run "python setup.py bdist_msi"

Expected behavior
an msi installer output

**Desktop Info

  • Platform information (windows 8.1):
  • OS architecture (e.g. 64bit):
  • cx_Freeze version [ 6.7]:
  • Python version [ 3.7 32bit]:
@marcelotduarte
Copy link
Owner

I cannot reproduce this issue. Can you put more information?

  • if your installation is from python.org, conda, etc.
  • complete traceback

@Dennis-Asamoah
Copy link
Author

Installation is from python.org . Also i only encountered the problem in version cx-freeze 6.7.
The other version (version 6.6) works without any error with the same setup.py .

@marcelotduarte
Copy link
Owner

Can you put a complete traceback?

@Dennis-Asamoah
Copy link
Author

Dennis-Asamoah commented Aug 10, 2021

Traceback (most recent call last):
  File "setup.py", line 98, in <module>
    executables=executables
  File "C:\Program Files (x86)\Python37-32\lib\site-packages\cx_Freeze\dist.py",  line 437, in setup
    distutils.core.setup(**attrs)
  File "C:\Program Files (x86)\Python37-32\lib\distutils\core.py", line 148, in setup
    dist.run_commands()
  File "C:\Program Files (x86)\Python37-32\lib\distutils\dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "C:\Program Files (x86)\Python37-32\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "C:\Program Files (x86)\Python37-32\lib\site-packages\cx_Freeze\windist.py", line 968, in run
    self.add_files()
  File "C:\Program Files (x86)\Python37-32\lib\site-packages\cx_Freeze\windist.py", line 326, in add_files
    keyfile=file,
  File "C:\Program Files (x86)\Python37-32\lib\msilib\__init__.py", line 276, in start_component
    keyid = self.cab.gen_id(self.absolute, keyfile)
TypeError: gen_id() takes 2 positional arguments but 3 were given

@marcelotduarte
Copy link
Owner

marcelotduarte commented Aug 10, 2021

Can you test for me with the previous beta versions, I believe that the bug was introduced between 6.7b1 6.7b or 6.7b3 but I release 8 betas.
To install beta:
pip install cx_Freeze==6.7b1

Test and put the traceback if necessary (see the previous comment edited).

@Dennis-Asamoah
Copy link
Author

Dennis-Asamoah commented Aug 10, 2021

i tested 6.7b1,6.7b2....6.7b8(all the 6.7betas) and they all gave the same error .

Traceback (most recent call last):
File "setup.py", line 98, in
executables=executables
File "C:\Program Files (x86)\Python37-32\lib\site-packages\cx_Freeze\dist.py",
line 434, in setup
distutils.core.setup(**attrs)
File "C:\Program Files (x86)\Python37-32\lib\distutils\core.py", line 148, in
setup
dist.run_commands()
File "C:\Program Files (x86)\Python37-32\lib\distutils\dist.py", line 966, in
run_commands
self.run_command(cmd)
File "C:\Program Files (x86)\Python37-32\lib\distutils\dist.py", line 985, in
run_command
cmd_obj.run()
File "C:\Program Files (x86)\Python37-32\lib\site-packages\cx_Freeze\windist.p
y", line 968, in run
self.add_files()
File "C:\Program Files (x86)\Python37-32\lib\site-packages\cx_Freeze\windist.p
y", line 326, in add_files
keyfile=file,
File "C:\Program Files (x86)\Python37-32\lib\msilib_init_.py", line 276, in
start_component
keyid = self.cab.gen_id(self.absolute, keyfile)
TypeError: gen_id() takes 2 positional arguments but 3 were given


then i tested 6.8b1 and it gave me the below error:

Traceback (most recent call last):
File "setup.py", line 98, in
executables=executables
File "C:\Program Files (x86)\Python37-32\lib\site-packages\cx_Freeze\dist.py",
line 437, in setup
distutils.core.setup(**attrs)
File "C:\Program Files (x86)\Python37-32\lib\distutils\core.py", line 148, in
setup
dist.run_commands()
File "C:\Program Files (x86)\Python37-32\lib\distutils\dist.py", line 966, in
run_commands
self.run_command(cmd)
File "C:\Program Files (x86)\Python37-32\lib\distutils\dist.py", line 985, in
run_command
cmd_obj.run()
File "C:\Program Files (x86)\Python37-32\lib\site-packages\cx_Freeze\windist.p
y", line 925, in run
self.run_command("build")
File "C:\Program Files (x86)\Python37-32\lib\distutils\cmd.py", line 313, in r
un_command
self.distribution.run_command(command)
File "C:\Program Files (x86)\Python37-32\lib\distutils\dist.py", line 985, in
run_command
cmd_obj.run()
File "C:\Program Files (x86)\Python37-32\lib\distutils\command\build.py", line
135, in run
self.run_command(cmd_name)
File "C:\Program Files (x86)\Python37-32\lib\distutils\cmd.py", line 313, in r
un_command
self.distribution.run_command(command)
File "C:\Program Files (x86)\Python37-32\lib\distutils\dist.py", line 985, in
run_command
cmd_obj.run()
File "C:\Program Files (x86)\Python37-32\lib\site-packages\cx_Freeze\dist.py",
line 305, in run
freezer.Freeze()
File "C:\Program Files (x86)\Python37-32\lib\site-packages\cx_Freeze\freezer.p
y", line 609, in Freeze
self._write_modules(filename, self.finder)
File "C:\Program Files (x86)\Python37-32\lib\site-packages\cx_Freeze\freezer.p
y", line 489, in _write_modules
print("Removing", folder_to_remove + "...")
TypeError: unsupported operand type(s) for +: 'WindowsPath' and 'str'

@marcelotduarte
Copy link
Owner

6.8b1 has this bug.
Between version 6.6 (April 14) and 6.7b1 (May 23), there are five PR to this module. But I think that the offending is the first (see PR #1032) because introduces a new comparison.
Do you use some bdis_msi option?

@Cimbali
Copy link
Contributor

Cimbali commented Aug 11, 2021

I think the issue is an msilib that’s not up to date, no? It should look like this, not like keyid = self.cab.gen_id(self.absolute, keyfile) which causes the error

https://github.com/python/cpython/blob/c174eafc33999b9e773a5ea9561ad38886f1a0e6/Lib/msilib/__init__.py#L275-L277

This was fixed 2 years ago, see python/cpython@c8d5bf6

@marcelotduarte
Copy link
Owner

@Dennis-Asamoah What is the version of python 3.7? You should upgrade to 3.7.4 or up (3.7.9 is the last with an installer).
Please report
Thanks @Cimbali

@Dennis-Asamoah
Copy link
Author

Ok thanks @marcelotduarte and @Cimbali .
Please i want to ask if there is a way to run the setup once only on a single pc ,after which the setup cannot run on any other pc, or a way to automatically delete the setup after it finishes installing .

@marcelotduarte
Copy link
Owner

I did not understand your question. Are you looking for a way to protect the installation, for example, against piracy?

So to confirm the issue: What is your installed version of python 3.7?

@Dennis-Asamoah
Copy link
Author

My python version is 3.7.2.

Yes to prevent against piracy. I want the software created to run only on one single pc. Meaning after installation, is there a way to prevent the .msi from being run on other pc after the first installation on an initial pc. In other words the .msi becomes unusable after using it only once .I would be happy if you help me.

@marcelotduarte
Copy link
Owner

This is off-topic. You should find some package or a method to license your program.
msi is modifiable and not protected. See https://stackoverflow.com/questions/56969925/how-to-protect-msi-against-modification

@Cimbali
Copy link
Contributor

Cimbali commented Aug 12, 2021

I think the only thing you can do with msi is add signatures, and I don’t know how you’d do that with cx_Freeze. You certainly can’t delete the installer (and then what? users could copy the file before installing, no? Or get it again from where they got it from?) − on the contrary I think windows often keeps a copy of the installer in some system directory to know how to uninstall.

But that’s indeed unrelated to the bug.

@marcelotduarte
Copy link
Owner

the only thing you can do with msi is add signatures, and I don’t know how you’d do that with cx_Freeze

In #203 has a method

@Dennis-Asamoah
Copy link
Author

@Cimbali and @marcelotduarte ,
thank you guys

@marcelotduarte
Copy link
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants