这是我自己的本地软件包,尝试安装它并始终收到以下错误。
C:\Users\Ron\Desktop\mypkg>pip install -e C:\Users\Ron\Desktop\mypkg
Obtaining file:///C:\Users\Ron\Desktop\mypkg
    ERROR: Command errored out with exit status 1:
     command: 'd:\python\python38-32\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Ron\\Desktop\\mypkg\\setup.py'"'"'; __file__='"'"'C:\\Users\\Ron\\Desktop\\mypkg\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info
         cwd: C:\Users\Ron\Desktop\mypkg\
    Complete output (25 lines):
    running egg_info
    writing mypkg.egg-info\PKG-INFO
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\Ron\Desktop\mypkg\setup.py", line 7, in <module>
        setup(name="mypkg",
      File "d:\python\python38-32\lib\site-packages\setuptools\__init__.py", line 144, in setup
        return distutils.core.setup(\*attrs)
      File "d:\python\python38-32\lib\distutils\core.py", line 148, in setup
        dist.run_commands()
      File "d:\python\python38-32\lib\distutils\dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "d:\python\python38-32\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "d:\python\python38-32\lib\site-packages\setuptools\command\egg_info.py", line 290, in run
        writer(self, ep.name, os.path.join(self.egg_info, ep.name))
      File "d:\python\python38-32\lib\site-packages\setuptools\command\egg_info.py", line 622, in write_pkg_info
        metadata.write_pkg_info(cmd.egg_info)
      File "d:\python\python38-32\lib\distutils\dist.py", line 1117, in write_pkg_info
        self.write_pkg_file(pkg_info)
      File "d:\python\python38-32\lib\site-packages\setuptools\dist.py", line 164, in write_pkg_file
        long_desc = rfc822_escape(self.get_long_description())
      File "d:\python\python38-32\lib\distutils\util.py", line 475, in rfc822_escape
        lines = header.split('\n')
    AttributeError: 'function' object has no attribute 'split'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
C:\Users\Ron\Desktop\mypkg>
 
生成的PKG-INFO:
Metadata-Version: 2.1
Name: mypkg
Version: 0.1.0
Summary: BETA
Home-page: https://github.com/CENSURED/mypkg
License: UNKNOWN
 
Setup.py:
from setuptools import setup
def readme():
    with open('README.md') as file:
        return file.read()
setup(name="mypkg",
      version="0.1.0",
      description="BETA",
      long_description=readme,
      long_description_content_type="text/markdown",
      classifiers=[
          "Programming Language :: Python :: 3",
          "Operating System :: (ANY) Windows"
      ],
      url="https://github.com/CENSURED/mypkg",
      packages=setuptools.find_packages(),
      python_requires='>=3.6'
    )
 
--Aleadry尝试更新设置工具|||||||||||||||||||||||||||||||||||||||||| ||||||||||||||||||||||||||||| --Aleadry尝试使用setup.py模板(显然是对其进行了编辑)
问题来源:stackoverflow
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
错误的原因是因为long_description参数需要一个字符串,但是您已传入一个函数。我相信您的意图是调用函数,而不是传递函数本身:
from setuptools import setup
def readme():
    with open('README.md') as file:
        return file.read()
setup(name="mypkg",
      version="0.1.0",
      description="BETA",
      long_description=readme(), # call the function here
      long_description_content_type="text/markdown",
      classifiers=[
          "Programming Language :: Python :: 3",
          "Operating System :: (ANY) Windows"
      ],
      url="https://github.com/CENSURED/mypkg",
      packages=setuptools.find_packages(),
      python_requires='>=3.6'
    )
 
回答来源:stackoverflow