PyPI模块上传后安装失败求助:mousecontroller模块构建Wheel报错
Looks like that frustrating error boils down to a small syntax misstep in your setup.py file—let's get it sorted out quickly!
What's Causing the Error?
The log shows it's looking for a file named 'm' because you passed a single string to the scripts parameter in the setup() function. Setuptools expects scripts to be a list of file paths, not a single string. When you pass just 'mousecontroller.py', Python treats that string as an iterable, so it tries to process each character as a separate script file—starting with the first character, 'm', which obviously doesn't exist as a file.
Corrected setup.py Code
Here's the fixed version, with the critical change to the scripts line (now wrapped in square brackets to make it a list):
from setuptools import setup, find_packages setup( name='mousecontroller', version='1.0.2', author='(我的姓名)', author_email='(我的邮箱)', 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'], # Changed to a list instead of single string install_requires=['pypiwin32', 'keyboard'], classifiers=[ "Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", ], )
Bonus: Modern Alternative to scripts
For better compatibility across environments, modern Python packaging recommends using entry_points instead of scripts. If you want to update to this approach, replace the scripts line with this:
entry_points={ 'console_scripts': [ 'mousecontroller=mousecontroller:main', # Replace 'main' with your actual entry function name ], }
Just ensure your mousecontroller.py has a main() function that triggers your tool's core logic.
Next Steps
After updating your setup.py, rebuild your package with:
python setup.py sdist bdist_wheel
Then re-upload to PyPI using twine, and running pip install mousecontroller should work without that error.
内容的提问来源于stack exchange,提问作者Atomic Peanut

