dawaeboi
dawaeboi

Reputation: 25

{Python 3.8} Pip command error on setuptools

It's my local own package, trying to install it and always get the error below.

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>

Generated 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 tried to update setuptools |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| --Aleadry tried to use a setup.py template (edited it, obviously)

Upvotes: 0

Views: 2351

Answers (1)

jordanm
jordanm

Reputation: 34914

The reason for the error is because the long_description parameter expects a string, but you have passed in a function. I believe your intent was to call the function, rather than passing the function itself:

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'
    )

Upvotes: 3

Related Questions