幾個python虛擬環境會遇到的問題
- 'twine' is not recognized as an internal or external command,operable program or batch file.
- setup命令不報錯但不起作用
- 'pipreqs' is not recognized as an internal or external command,operable program or batch file.
‘twine’ is not recognized as an internal or external command,operable program or batch file.
這個錯誤的時候可以使用以下方式
(python39) D:\workspace\Python\BottlePie>python -m twine upload dist/*
Uploading distributions to https://upload.pypi.org/legacy/
Enter your username: jiangcheng1806
Enter your password:
Uploading todolist_JIANG.CHENG-0.0.1-py3-none-any.whl
100% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 8.3/8.3 kB ? 00:00 ? ?
Uploading todolist-JIANG.CHENG-0.0.1.tar.gz
100% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 7.5/7.5 kB ? 00:00 ? ?
View at:
https://pypi.org/project/todolist-JIANG.CHENG/0.0.1/
(python39) D:\workspace\Python\BottlePie>
參考的解釋:https://stackoverflow.com/questions/51469451/issue-uploading-a-python-package-to-pypi-using-windoes-10-twine-is-not-recogni
setup命令不報錯但不起作用
在文件夾下使用python開頭執行setup.py沒有響應,這也是虛擬環境問題,需要到虛擬環境下執行
‘pipreqs’ is not recognized as an internal or external command,operable program or batch file.
要生成requirements,需要使用pipreqs,但是以下命令報錯了
(python39) D:\workspace\Python\BottlePie>python pipreqs . --encoding=utf8 --force
python: can’t open file ‘D:\workspace\Python\BottlePie\pipreqs’: [Errno 2] No such file or directory
(python39) D:\workspace\Python\BottlePie>python pip -m pipreqs . --encoding=utf8 --force
python: can’t open file ‘D:\workspace\Python\BottlePie\pip’: [Errno 2] No such file or directory
(python39) D:\workspace\Python\BottlePie>python -m pipreqs . --encoding=utf8 --force
D:\ProgramData\anaconda3\envs\python39\python.exe: No module named pipreqs.main; ‘pipreqs’ is a package and cannot be directly executed
最終使用以下命令成功運行
python -m pipreqs.pipreqs . --encoding=utf8 --force