python-3.x - pip 脚本未运行
问题描述
我使用这个命令来上传 pypi pkg
python2 setup.py sdist
python2 setup.py bdist_wheel
python2 -m twine upload dist/* --skip-exis
我的包 https://pypi.org/project/abir/0.1/
当我 inatall pip install abir in install 成功但是当我运行 abir 它告诉我这个错误任何人都可以帮助我解决这个问题
/data/data/com.termux/files/usr/bin/abir: line 2: import: command not found
/data/data/com.termux/files/usr/bin/abir: line 3: from: command not found
/data/data/com.termux/files/usr/bin/abir: line 4: try:: command not found
/data/data/com.termux/files/usr/bin/abir: line 5: import: command not found
/data/data/com.termux/files/usr/bin/abir: line 6: except: command not found
/data/data/com.termux/files/usr/bin/abir: line 7: syntax error near unexpected token `'pip2 install mechanize''
/data/data/com.termux/files/usr/bin/abir: line 7: ` os.system('pip2 install mechanize')'
检查那个pypi文件并告诉我 这个脚本版本是python2.7的答案
我的 setup.py 文件
import setuptools
with open("README.md", "r") as fh:
long_description = fh.read()
setuptools.setup(
name='abir',
version='0.1',
scripts=['abir'] ,
author="ABIR HOSSAIN",
author_email="abirhossain200019@gmail.com",
description="this is a test file",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/ABIRHOSSAIN10/test",
packages=setuptools.find_packages(),
classifiers=[
"Programming Language :: Python :: 2.7",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
)
解决方案
您的脚本abir
不是以shebang开头的,因此命令行 shell 假定它是一个 shell 脚本。因此,这不是这些语法错误。
要修复脚本:
添加一个shebang:插入
#!/usr/bin/python
或者
#!/usr/bin/env python
作为脚本的第一行。
增加版本;做它0.1.1
或0.2
。
生成一个新的 sdist 和一个新的 wheel 包。
将新包上传到 PyPI。升级:
pip install -U abir
测试:
abir
推荐阅读
- html - 从 DOM 中删除 CSS 样式表
- pdf - 有没有办法在 rmarkdown 中将文本环绕在图像周围,同时兼容 pdf 和 html?
- matplotlib - matplotlib - 用组栏绘制合并的数据框
- android - 平滑地为 BottomSheet 窥视高度设置动画
- azure - Azure 资源移动器失败,但资源已移动
- python - 如何在 pyproject.toml 文件中配置 os 特定的依赖项 [Maturin]
- r - 线性回归模型函数中没有返回值
- javascript - 为什么使用模型的 find() 在注册路径中不起作用?
- r - 如何根据输入条件禁用按钮?
- string - 在 spark scala 中将日期从字符串转换为日期时间