python-setup.py sdist bdist\u wheel

python-setup.py sdist bdist\u wheel,python,pip,setuptools,python-packaging,Python,Pip,Setuptools,Python Packaging,我决定创建一个名为“NsmPY”的小模块。一旦我完成了模块背后的代码(可在GitHub上获得),我就开始尝试将这个新模块上传到PyPi。但是,当我运行必要的命令python3 setup.py sdist bdist_wheel时,程序抛出了一个错误: running sdist running egg_info writing nsmpy.egg-info\PKG-INFO writing dependency_links to nsmpy.egg-info\dependency_links.

我决定创建一个名为“NsmPY”的小模块。一旦我完成了模块背后的代码(可在GitHub上获得),我就开始尝试将这个新模块上传到PyPi。但是,当我运行必要的命令python3 setup.py sdist bdist_wheel时,程序抛出了一个错误:

running sdist
running egg_info
writing nsmpy.egg-info\PKG-INFO
writing dependency_links to nsmpy.egg-info\dependency_links.txt
writing top-level names to nsmpy.egg-info\top_level.txt
reading manifest file 'nsmpy.egg-info\SOURCES.txt'
writing manifest file 'nsmpy.egg-info\SOURCES.txt'
warning: sdist: standard file not found: should have one of README, README.rst, README.txt, README.md

running check
creating nsmpy-1.0
creating nsmpy-1.0\nsmpy.egg-info
copying files to nsmpy-1.0...
copying setup.cfg -> nsmpy-1.0
copying setup.py -> nsmpy-1.0
copying nsmpy.egg-info\PKG-INFO -> nsmpy-1.0\nsmpy.egg-info
copying nsmpy.egg-info\SOURCES.txt -> nsmpy-1.0\nsmpy.egg-info
copying nsmpy.egg-info\dependency_links.txt -> nsmpy-1.0\nsmpy.egg-info
copying nsmpy.egg-info\top_level.txt -> nsmpy-1.0\nsmpy.egg-info
Writing nsmpy-1.0\setup.cfg
Creating tar archive
removing 'nsmpy-1.0' (and everything under it)
running bdist_wheel
running build
running build_scripts
creating build
creating build\scripts-3.7
error: [Errno 2] No such file or directory: 'nsmpy'
但是,在我的代码中绝对没有提到文件或目录“nsmpy”,即使如此,代码、setup.py、setup.cfg和所有其他安装文件都存储在文件夹“nsmpy”中

此外,当我最终在PyPi上上传到我的帐户时(我运行了
python setup.py sdist
),它确实起了作用-直到我决定使用
pip install nsmpy
安装模块,它给了我以下错误:

Collecting nsmpy==1.0.0
  Using cached nsmpy-1.0.tar.gz (628 bytes)
Building wheels for collected packages: nsmpy
  Building wheel for nsmpy (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: 'c:\users\sciencepi\anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\SCIENC~1\\AppData\\Local\\Temp\\pip-install-98ihityv\\nsmpy\\setup.py'"'"'; __file__='"'"'C:\\Users\\SCIENC~1\\AppData\\Local\\Temp\\pip-install-98ihityv\\nsmpy\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\SCIENC~1\AppData\Local\Temp\pip-wheel-mm6p5lwl'
       cwd: C:\Users\SCIENC~1\AppData\Local\Temp\pip-install-98ihityv\nsmpy\
  Complete output (6 lines):
  running bdist_wheel
  running build
  running build_scripts
  creating build
  creating build\scripts-3.7
  error: [Errno 2] No such file or directory: 'nsmpy'
  ----------------------------------------
  ERROR: Failed building wheel for nsmpy
  Running setup.py clean for nsmpy
Failed to build nsmpy
ERROR: Error checking for conflicts.
Traceback (most recent call last):
  File "c:\users\sciencepi\anaconda3\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 3021, in _dep_map
    return self.__dep_map
  File "c:\users\sciencepi\anaconda3\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 2815, in __getattr__
    raise AttributeError(attr)
AttributeError: _DistInfoDistribution__dep_map

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\sciencepi\anaconda3\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 3012, in _parsed_pkg_info
    return self._pkg_info
  File "c:\users\sciencepi\anaconda3\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 2815, in __getattr__
    raise AttributeError(attr)
AttributeError: _pkg_info

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\sciencepi\anaconda3\lib\site-packages\pip\_internal\commands\install.py", line 517, in _warn_about_conflicts
    package_set, _dep_info = check_install_conflicts(to_install)
  File "c:\users\sciencepi\anaconda3\lib\site-packages\pip\_internal\operations\check.py", line 114, in check_install_conflicts
    package_set, _ = create_package_set_from_installed()
  File "c:\users\sciencepi\anaconda3\lib\site-packages\pip\_internal\operations\check.py", line 53, in create_package_set_from_installed
    package_set[name] = PackageDetails(dist.version, dist.requires())
  File "c:\users\sciencepi\anaconda3\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 2736, in requires
    dm = self._dep_map
  File "c:\users\sciencepi\anaconda3\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 3023, in _dep_map
    self.__dep_map = self._compute_dependencies()
  File "c:\users\sciencepi\anaconda3\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 3032, in _compute_dependencies
    for req in self._parsed_pkg_info.get_all('Requires-Dist') or []:
  File "c:\users\sciencepi\anaconda3\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 3014, in _parsed_pkg_info
    metadata = self.get_metadata(self.PKG_INFO)
  File "c:\users\sciencepi\anaconda3\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 1420, in get_metadata
    value = self._get(path)
  File "c:\users\sciencepi\anaconda3\lib\site-packages\pip\_vendor\pkg_resources\__init__.py", line 1616, in _get
    with open(path, 'rb') as stream:
PermissionError: [Errno 13] Permission denied: 'c:\\users\\sciencepi\\anaconda3\\lib\\site-packages\\tensorflow-2.1.0.dist-info\\METADATA'
Installing collected packages: nsmpy
    Running setup.py install for nsmpy ... error
    ERROR: Command errored out with exit status 1:
     command: 'c:\users\sciencepi\anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\SCIENC~1\\AppData\\Local\\Temp\\pip-install-98ihityv\\nsmpy\\setup.py'"'"'; __file__='"'"'C:\\Users\\SCIENC~1\\AppData\\Local\\Temp\\pip-install-98ihityv\\nsmpy\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\SCIENC~1\AppData\Local\Temp\pip-record-9ap1k2wf\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\sciencepi\anaconda3\Include\nsmpy'
         cwd: C:\Users\SCIENC~1\AppData\Local\Temp\pip-install-98ihityv\nsmpy\
    Complete output (6 lines):
    running install
    running build
    running build_scripts
    creating build
    creating build\scripts-3.7
    error: file 'C:\Users\SCIENC~1\AppData\Local\Temp\pip-install-98ihityv\nsmpy\nsmpy' does not exist
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\sciencepi\anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\SCIENC~1\\AppData\\Local\\Temp\\pip-install-98ihityv\\nsmpy\\setup.py'"'"'; __file__='"'"'C:\\Users\\SCIENC~1\\AppData\\Local\\Temp\\pip-install-98ihityv\\nsmpy\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\SCIENC~1\AppData\Local\Temp\pip-record-9ap1k2wf\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\sciencepi\anaconda3\Include\nsmpy' Check the logs for full command output.
是的,我正在使用最新的模块和最新的版本

from setuptools import setup

setup(
    name="nsmpy",
    version="1.0.0",
    scripts=['nsmpy'])


setuptools.setup
函数的
scripts
参数应该是文件名列表。因此,就你的情况而言,我认为应该是:

setuptools.setup(
    # ...
    scripts=['nsmpy.py'],
    # ...
)
还要注意,
scripts
参数有些不受欢迎。现在建议使用
console\u脚本
入口点,因为有更多的最新文档可用

参考资料:


setup.py文件看起来怎么样?老实说,有些人不喜欢帖子,因为他们可以;这是stackoverflow需要解决的问题。我投了反对票,因为简言之:这个问题对更大的社区没有太大价值,它只帮助解决了一个特定的问题,几乎没有其他人可能会遇到这个问题(因为它是一个打字错误),如果他们这样做了,他们就不可能从搜索引擎中找到这篇文章。否决票不应被视为一种惩罚,通常它们只是意味着问题(及其答案)不太可能帮助其他人。在这种情况下,本网站上所有问题的90%以上的投票率为-20。而且,这不是一个打字错误,我强烈地感觉到每一篇文章都有一个目的,因此有这个问题的人可能会从这篇文章中得到帮助。当你投否决票时,它会使那些需要它的人更难获得该帖子。一个问题的全部意义,无论多么无关紧要,都是为了帮助任何提出该问题的人,以及帮助那些有类似问题的人。这个问题也不是研究得很差,我问这个问题的原因是因为我已经做了研究,并且没有其他错误的例子。因此,您的评论无效,将被标记。