Search code examples
pythonpippackagepypi

PyPI: Problems uploading a module


I am trying to upload a python module to PyPI using setuptools and twine. My module can be seen at https://pypi.org/project/mousecontroller/. If you try installing the module using pip install mousecontroller, you will encounter an error:

Collecting mousecontroller
  Using cached mousecontroller-1.0.2.tar.gz (1.4 kB)
  Preparing metadata (setup.py) ... done
Requirement already satisfied: pypiwin32 in c:\users\me\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packa
ges (from mousecontroller) (223)
Requirement already satisfied: keyboard in c:\users\me\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packag
es (from mousecontroller) (0.13.5)
Requirement already satisfied: pywin32>=223 in c:\users\me\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-pa
ckages (from pypiwin32->mousecontroller) (304)
Building wheels for collected packages: mousecontroller
  Building wheel for mousecontroller (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [6 lines of output]
      running bdist_wheel
      running build
      running build_scripts
      creating build
      creating build\scripts-3.9
      error: [Errno 2] No such file or directory: 'm'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for mousecontroller
  Running setup.py clean for mousecontroller
Failed to build mousecontroller
Installing collected packages: mousecontroller
  Running setup.py install for mousecontroller ... error
  error: subprocess-exited-with-error

  × Running setup.py install for mousecontroller did not run successfully.
  │ exit code: 1
  ╰─> [8 lines of output]
      running install
      C:\Users\me\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\setuptools\command\install.py:34:
SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build
      running build_scripts
      creating build
      creating build\scripts-3.9
      error: file 'C:\Users\me\AppData\Local\Temp\pip-install-60u406eb\mousecontroller_e9ecf1693b5a49f6aa898bb92d39281a\m' does not exist
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> mousecontroller

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

I have done some research on this problem and still have not found anything relevant to me or how to fix this. Here is my setup.py file:

from setuptools import setup, find_packages

setup(
    name='mousecontroller',
    version='1.0.2',
    author='(my name)',
    author_email='(my e-mail)',
    packages=find_packages(),
    url='https://pypi.org/project/mousecontroller/',
    license='LICENSE',
    description='A python package to easily control the mouse in realistic and fluent ways.',
    long_description=open('README.md', 'r').read(),
    long_description_content_type="text/markdown",
    scripts='mousecontroller.py',
    install_requires=['pypiwin32', 'keyboard'],
    classifiers=[
        "Programming Language :: Python :: 3",
        "License :: OSI Approved :: MIT License",
        "Operating System :: OS Independent",
    ],
)

note: I have edited the code and log to protect some of my personal information.


Solution

  • Your script= line is not correct, see the docs:

    The scripts option simply is a list of files

    You only provided your script as a string, which is split into individual characters when treated as a list. That is why the error message says that C:\Users\me\AppData\Local\Temp\pip-install-60u406eb\mousecontroller_e9ecf1693b5a49f6aa898bb92d39281a\m is not found.

    Fix by using squared brackets:

    scripts=['mousecontroller.py']
    

    Side Note

    mousecontroller.py
    

    is not in the .tar.gz that is available on PyPi. Might be due to the same reason.