TypeError: copy_file() takes from 2 to 7 positional arguments but 8 were given

Hi there,
I face error at the end of the “.whl” generation file with both wxpython 4.2.2 and 4.2.4.
I use Fedora 43 / python 3.14.

I launch the command :
pip wheel -v wxPython-4.2.2.tar.gz 2>&1 | tee build.log

And it fails with this message :
TypeError: copy_file() takes from 2 to 7 positional arguments but 8 were given

  ------------ BUILD FINISHED ------------
  To use wxPython from the build folder (without installing):
   - Set your PYTHONPATH variable to /tmp/pip-req-build-nzpvslec.
   - You may also need to set your (DY)LD_LIBRARY_PATH to /tmp/pip-req-build-nzpvslec/build/wxbld/gtk3/lib,
     or wherever the wxWidgets libs have been installed.

  Finished command: build_py (17m33.230s)
  Finished command: build (25m34.929s)
  Done!
  WARNING: Building this way assumes that all generated files have been
  generated already.  If that is not the case then use build.py directly
  to generate the source and perform the build stage.  You can use
  --skip-build with the bdist_* or install commands to avoid this
  message and the wxWidgets and Phoenix build steps in the future.

  "/home/kredge/Development/GestConsoPhoenix4.2.2--1.4.4/env4.2.4-py3.14/bin/python" -u build.py build
  running build_py
  creating build/lib.linux-x86_64-cpython-314/wx
  Traceback (most recent call last):
    File "/home/kredge/Development/GestConsoPhoenix4.2.2--1.4.4/env4.2.4-py3.14/lib64/python3.14/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 389, in <module>
      main()
      ~~~~^^
    File "/home/kredge/Development/GestConsoPhoenix4.2.2--1.4.4/env4.2.4-py3.14/lib64/python3.14/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 373, in main
      json_out["return_val"] = hook(**hook_input["kwargs"])
                               ~~~~^^^^^^^^^^^^^^^^^^^^^^^^
    File "/home/kredge/Development/GestConsoPhoenix4.2.2--1.4.4/env4.2.4-py3.14/lib64/python3.14/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 280, in build_wheel
      return _build_backend().build_wheel(
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
          wheel_directory, config_settings, metadata_directory
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      )
      ^
    File "/tmp/pip-build-env-9qiygpxx/overlay/lib/python3.14/site-packages/setuptools/build_meta.py", line 441, in build_wheel
      return _build(['bdist_wheel', '--dist-info-dir', str(metadata_directory)])
    File "/tmp/pip-build-env-9qiygpxx/overlay/lib/python3.14/site-packages/setuptools/build_meta.py", line 429, in _build
      return self._build_with_temp_dir(
             ~~~~~~~~~~~~~~~~~~~~~~~~~^
          cmd,
          ^^^^
      ...<3 lines>...
          self._arbitrary_args(config_settings),
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      )
      ^
    File "/tmp/pip-build-env-9qiygpxx/overlay/lib/python3.14/site-packages/setuptools/build_meta.py", line 410, in _build_with_temp_dir
      self.run_setup()
      ~~~~~~~~~~~~~~^^
    File "/tmp/pip-build-env-9qiygpxx/overlay/lib/python3.14/site-packages/setuptools/build_meta.py", line 520, in run_setup
      super().run_setup(setup_script=setup_script)
      ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/tmp/pip-build-env-9qiygpxx/overlay/lib/python3.14/site-packages/setuptools/build_meta.py", line 317, in run_setup
      exec(code, locals())
      ~~~~^^^^^^^^^^^^^^^^
    File "<string>", line 364, in <module>
    File "/tmp/pip-build-env-9qiygpxx/overlay/lib/python3.14/site-packages/setuptools/__init__.py", line 117, in setup
      return distutils.core.setup(**attrs)  # type: ignore[return-value]
             ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
    File "/tmp/pip-build-env-9qiygpxx/overlay/lib/python3.14/site-packages/setuptools/_distutils/core.py", line 186, in setup
      return run_commands(dist)
    File "/tmp/pip-build-env-9qiygpxx/overlay/lib/python3.14/site-packages/setuptools/_distutils/core.py", line 202, in run_commands
      dist.run_commands()
      ~~~~~~~~~~~~~~~~~^^
    File "/tmp/pip-build-env-9qiygpxx/overlay/lib/python3.14/site-packages/setuptools/_distutils/dist.py", line 1000, in run_commands
      self.run_command(cmd)
      ~~~~~~~~~~~~~~~~^^^^^
    File "/tmp/pip-build-env-9qiygpxx/overlay/lib/python3.14/site-packages/setuptools/dist.py", line 1107, in run_command
      super().run_command(command)
      ~~~~~~~~~~~~~~~~~~~^^^^^^^^^
    File "/tmp/pip-build-env-9qiygpxx/overlay/lib/python3.14/site-packages/setuptools/_distutils/dist.py", line 1019, in run_command
      cmd_obj.run()
      ~~~~~~~~~~~^^
    File "<string>", line 230, in run
    File "/tmp/pip-build-env-9qiygpxx/overlay/lib/python3.14/site-packages/setuptools/_distutils/cmd.py", line 341, in run_command
      self.distribution.run_command(command)
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
    File "/tmp/pip-build-env-9qiygpxx/overlay/lib/python3.14/site-packages/setuptools/dist.py", line 1107, in run_command
      super().run_command(command)
      ~~~~~~~~~~~~~~~~~~~^^^^^^^^^
    File "/tmp/pip-build-env-9qiygpxx/overlay/lib/python3.14/site-packages/setuptools/_distutils/dist.py", line 1019, in run_command
      cmd_obj.run()
      ~~~~~~~~~~~^^
    File "<string>", line 144, in run
    File "/tmp/pip-build-env-9qiygpxx/overlay/lib/python3.14/site-packages/setuptools/_distutils/command/build.py", line 135, in run
      self.run_command(cmd_name)
      ~~~~~~~~~~~~~~~~^^^^^^^^^^
    File "/tmp/pip-build-env-9qiygpxx/overlay/lib/python3.14/site-packages/setuptools/_distutils/cmd.py", line 341, in run_command
      self.distribution.run_command(command)
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
    File "/tmp/pip-build-env-9qiygpxx/overlay/lib/python3.14/site-packages/setuptools/dist.py", line 1107, in run_command
      super().run_command(command)
      ~~~~~~~~~~~~~~~~~~~^^^^^^^^^
    File "/tmp/pip-build-env-9qiygpxx/overlay/lib/python3.14/site-packages/setuptools/_distutils/dist.py", line 1019, in run_command
      cmd_obj.run()
      ~~~~~~~~~~~^^
    File "/tmp/pip-build-env-9qiygpxx/overlay/lib/python3.14/site-packages/setuptools/command/build_py.py", line 79, in run
      self.build_packages()
      ~~~~~~~~~~~~~~~~~~~^^
    File "/tmp/pip-build-env-9qiygpxx/overlay/lib/python3.14/site-packages/setuptools/_distutils/command/build_py.py", line 380, in build_packages
      self.build_module(module, module_file, package)
      ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/tmp/pip-build-env-9qiygpxx/overlay/lib/python3.14/site-packages/setuptools/_distutils/command/build_py.py", line 351, in build_module
      return self.copy_file(module_file, outfile, preserve_mode=False)
             ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/tmp/pip-build-env-9qiygpxx/overlay/lib/python3.14/site-packages/setuptools/command/build_py.py", line 66, in copy_file
      return super().copy_file(  # pyright: ignore[reportReturnType] # pypa/distutils#309
             ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          infile, outfile, preserve_mode, preserve_times, link, level
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      )
      ^
    File "/tmp/pip-build-env-9qiygpxx/overlay/lib/python3.14/site-packages/setuptools/_distutils/cmd.py", line 405, in copy_file
      return file_util.copy_file(
             ~~~~~~~~~~~~~~~~~~~^
          infile,
          ^^^^^^^
      ...<4 lines>...
          link,
          ^^^^^
      )
      ^
    File "<string>", line 287, in wx_copy_file
  TypeError: copy_file() takes from 2 to 7 positional arguments but 8 were given
  error: subprocess-exited-with-error
  
  × Building wheel for wxPython (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> No available output.
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  full command: /home/kredge/Development/GestConsoPhoenix4.2.2--1.4.4/env4.2.4-py3.14/bin/python /home/kredge/Development/GestConsoPhoenix4.2.2--1.4.4/env4.2.4-py3.14/lib64/python3.14/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py build_wheel /tmp/tmp22rqx7zk
  cwd: /tmp/pip-req-build-nzpvslec
  Building wheel for wxPython (pyproject.toml): finished with status 'error'
  ERROR: Failed building wheel for wxPython
Failed to build wxPython
ERROR: Failed to build one or more wheels 

Any idea to this issue ?

Thanks a lot.

1 Like

Sigh, yeah this is something I noticed yesterday. wxPython monkey-patches parts of distutils (part of setuptools now) and there was a setuptools update yesterday that broke our monkey-patching.

As a workaround, you should be able to downgrade to setuptools < 81.

I’ve already fixed this in the master branch, but I guess we might need a new 4.2.x release. :frowning:

Thank you swt2c for your reply.
I changed six/wheel/setuptools with their versions who worked out fine on another Linux distrib (Winux) :
six : 1.17.0
wheel : 0.45.1
setuptools : 80.9.0
But on Fedora 43 the issue remains the same…
What do you think about these same versions ? ok on Winux, but ko on Fedora. Isn’t there another problem than setuptools version on your opinion ?
Thx again :slight_smile:

I am not sure. Are you 100% sure you’re using setuptools < 81 on Fedora 43? Also, the error is the exact same?

Right, I’m sure :

Python 3.14.2 (main, Dec  5 2025, 00:00:00) [GCC 15.2.1 20251111 (Red Hat 15.2.1-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import six
>>> print (six.__version__)
1.17.0
>>> import wheel
>>> print (wheel.__version__)
0.45.1
>>> import setuptools
>>> print (setuptools.__version__)
80.9.0
>>> 

And error code seems the same :

  ------------ BUILD FINISHED ------------
  To use wxPython from the build folder (without installing):
   - Set your PYTHONPATH variable to /tmp/pip-req-build-7yivudf6.
   - You may also need to set your (DY)LD_LIBRARY_PATH to /tmp/pip-req-build-7yivudf6/build/wxbld/gtk3/lib,
     or wherever the wxWidgets libs have been installed.

  Finished command: build_py (17m38.685s)
  Finished command: build (25m48.650s)
  Done!
  WARNING: Building this way assumes that all generated files have been
  generated already.  If that is not the case then use build.py directly
  to generate the source and perform the build stage.  You can use
  --skip-build with the bdist_* or install commands to avoid this
  message and the wxWidgets and Phoenix build steps in the future.

  "/home/kredge/Development/GestConsoPhoenix4.2.2--1.4.4/env4.2.4-py3.14/bin/python" -u build.py build
  running build_py
  creating build/lib.linux-x86_64-cpython-314/wx
  Traceback (most recent call last):
    File "/home/kredge/Development/GestConsoPhoenix4.2.2--1.4.4/env4.2.4-py3.14/lib64/python3.14/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 389, in <module>
      main()
      ~~~~^^
    File "/home/kredge/Development/GestConsoPhoenix4.2.2--1.4.4/env4.2.4-py3.14/lib64/python3.14/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 373, in main
      json_out["return_val"] = hook(**hook_input["kwargs"])
                               ~~~~^^^^^^^^^^^^^^^^^^^^^^^^
    File "/home/kredge/Development/GestConsoPhoenix4.2.2--1.4.4/env4.2.4-py3.14/lib64/python3.14/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 280, in build_wheel
      return _build_backend().build_wheel(
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
          wheel_directory, config_settings, metadata_directory
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      )
      ^
    File "/tmp/pip-build-env-dv5cmx5s/overlay/lib/python3.14/site-packages/setuptools/build_meta.py", line 441, in build_wheel
      return _build(['bdist_wheel', '--dist-info-dir', str(metadata_directory)])
    File "/tmp/pip-build-env-dv5cmx5s/overlay/lib/python3.14/site-packages/setuptools/build_meta.py", line 429, in _build
      return self._build_with_temp_dir(
             ~~~~~~~~~~~~~~~~~~~~~~~~~^
          cmd,
          ^^^^
      ...<3 lines>...
          self._arbitrary_args(config_settings),
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      )
      ^
    File "/tmp/pip-build-env-dv5cmx5s/overlay/lib/python3.14/site-packages/setuptools/build_meta.py", line 410, in _build_with_temp_dir
      self.run_setup()
      ~~~~~~~~~~~~~~^^
    File "/tmp/pip-build-env-dv5cmx5s/overlay/lib/python3.14/site-packages/setuptools/build_meta.py", line 317, in run_setup
      exec(code, locals())
      ~~~~^^^^^^^^^^^^^^^^
    File "<string>", line 304, in <module>
    File "/tmp/pip-build-env-dv5cmx5s/overlay/lib/python3.14/site-packages/setuptools/__init__.py", line 117, in setup
      return distutils.core.setup(**attrs)  # type: ignore[return-value]
             ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
    File "/tmp/pip-build-env-dv5cmx5s/overlay/lib/python3.14/site-packages/setuptools/_distutils/core.py", line 186, in setup
      return run_commands(dist)
    File "/tmp/pip-build-env-dv5cmx5s/overlay/lib/python3.14/site-packages/setuptools/_distutils/core.py", line 202, in run_commands
      dist.run_commands()
      ~~~~~~~~~~~~~~~~~^^
    File "/tmp/pip-build-env-dv5cmx5s/overlay/lib/python3.14/site-packages/setuptools/_distutils/dist.py", line 1000, in run_commands
      self.run_command(cmd)
      ~~~~~~~~~~~~~~~~^^^^^
    File "/tmp/pip-build-env-dv5cmx5s/overlay/lib/python3.14/site-packages/setuptools/dist.py", line 1107, in run_command
      super().run_command(command)
      ~~~~~~~~~~~~~~~~~~~^^^^^^^^^
    File "/tmp/pip-build-env-dv5cmx5s/overlay/lib/python3.14/site-packages/setuptools/_distutils/dist.py", line 1019, in run_command
      cmd_obj.run()
      ~~~~~~~~~~~^^
    File "<string>", line 194, in run
    File "/tmp/pip-build-env-dv5cmx5s/overlay/lib/python3.14/site-packages/setuptools/_distutils/cmd.py", line 341, in run_command
      self.distribution.run_command(command)
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
    File "/tmp/pip-build-env-dv5cmx5s/overlay/lib/python3.14/site-packages/setuptools/dist.py", line 1107, in run_command
      super().run_command(command)
      ~~~~~~~~~~~~~~~~~~~^^^^^^^^^
    File "/tmp/pip-build-env-dv5cmx5s/overlay/lib/python3.14/site-packages/setuptools/_distutils/dist.py", line 1019, in run_command
      cmd_obj.run()
      ~~~~~~~~~~~^^
    File "<string>", line 110, in run
    File "/tmp/pip-build-env-dv5cmx5s/overlay/lib/python3.14/site-packages/setuptools/_distutils/command/build.py", line 135, in run
      self.run_command(cmd_name)
      ~~~~~~~~~~~~~~~~^^^^^^^^^^
    File "/tmp/pip-build-env-dv5cmx5s/overlay/lib/python3.14/site-packages/setuptools/_distutils/cmd.py", line 341, in run_command
      self.distribution.run_command(command)
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
    File "/tmp/pip-build-env-dv5cmx5s/overlay/lib/python3.14/site-packages/setuptools/dist.py", line 1107, in run_command
      super().run_command(command)
      ~~~~~~~~~~~~~~~~~~~^^^^^^^^^
    File "/tmp/pip-build-env-dv5cmx5s/overlay/lib/python3.14/site-packages/setuptools/_distutils/dist.py", line 1019, in run_command
      cmd_obj.run()
      ~~~~~~~~~~~^^
    File "/tmp/pip-build-env-dv5cmx5s/overlay/lib/python3.14/site-packages/setuptools/command/build_py.py", line 79, in run
      self.build_packages()
      ~~~~~~~~~~~~~~~~~~~^^
    File "/tmp/pip-build-env-dv5cmx5s/overlay/lib/python3.14/site-packages/setuptools/_distutils/command/build_py.py", line 380, in build_packages
      self.build_module(module, module_file, package)
      ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/tmp/pip-build-env-dv5cmx5s/overlay/lib/python3.14/site-packages/setuptools/_distutils/command/build_py.py", line 351, in build_module
      return self.copy_file(module_file, outfile, preserve_mode=False)
             ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/tmp/pip-build-env-dv5cmx5s/overlay/lib/python3.14/site-packages/setuptools/command/build_py.py", line 66, in copy_file
      return super().copy_file(  # pyright: ignore[reportReturnType] # pypa/distutils#309
             ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          infile, outfile, preserve_mode, preserve_times, link, level
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      )
      ^
    File "/tmp/pip-build-env-dv5cmx5s/overlay/lib/python3.14/site-packages/setuptools/_distutils/cmd.py", line 405, in copy_file
      return file_util.copy_file(
             ~~~~~~~~~~~~~~~~~~~^
          infile,
          ^^^^^^^
      ...<4 lines>...
          link,
          ^^^^^
      )
      ^
    File "<string>", line 249, in wx_copy_file
  TypeError: copy_file() takes from 2 to 7 positional arguments but 8 were given
  error: subprocess-exited-with-error
  
  × Building wheel for wxPython (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> No available output.
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  full command: /home/kredge/Development/GestConsoPhoenix4.2.2--1.4.4/env4.2.4-py3.14/bin/python /home/kredge/Development/GestConsoPhoenix4.2.2--1.4.4/env4.2.4-py3.14/lib64/python3.14/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py build_wheel /tmp/tmpp94ro9_b
  cwd: /tmp/pip-req-build-7yivudf6
  Building wheel for wxPython (pyproject.toml): finished with status 'error'
  ERROR: Failed building wheel for wxPython
Failed to build wxPython
ERROR: Failed to build one or more wheels

What do you think ?
Thanks.

the required account to reply sucks. anyway, here I am.

I downgraded setuptools (tried 80.9.0 and 78.1.1) in my venv, but when I pip install wxPython
build dependencies will be installed.

those include setuptool-81.0.0 on my system.

if I use
pip install wxPython “setuptools==80.1.0” (which SHOULD use 80.1.0)

it tells me
Requirement already satisfied: setuptools==80.1.0 in ./envir/lib/python3.13/site-packages (80.1.0)

BUT
if I access the /tmp/ working dir of the pip build environment
I find this:
/tmp/pip-build-env-ppyh3cc_/overlay/lib/python3.13/site-packages/setuptools-81.0.0.dist-info/

which suggests to me, that somethings goes wrong there.

I hope this helps. (even if it points to a pip bug, which is probably not to be solved here)

changing
wxPython-4.2.4/pyproject.toml
to contain
“setuptools>=70.1,<81.0.0”,
under
[build-system]
leads to
Successfully installed wxPython-4.2.4

Yeah, it seems that pip is installing its own copy of setuptools as part of the build process.

This workaround seems to work:

  1. Install pip 26.0.1 (needed for --build-constraint option).
  2. Create a file called older_setuptools.txt with the following contents:
    setuptools < 81
  3. Run pip install wxpython --build-constraint older_setuptools.txt

Thanks a lot swt2c, your workaround saves my night :slight_smile:
Problem solved :+1:

Also, I just released wxPython v4.2.5 which should resolve this issue as well.

2 Likes