当用PY Launcher调用模块时,为什么我必须用下划线替换所有连字符?
我正在使用 python parinterer Windows简化版本管理并避免修改系统路径。
我已经成功安装了一些软件包:
> py -m pip list
Package Version
------------------ ---------
Brotli 1.0.9
certifi 2021.10.8
charset-normalizer 2.0.12
gallery-dl 1.21.1
idna 3.3
mutagen 1.45.1
pip 22.0.4
pycryptodomex 3.14.1
requests 2.27.1
setuptools 58.1.0
urllib3 1.26.9
websockets 10.3
yt-dlp 2022.4.8
它们均在Program Files/Python310/Scripts
中列出:
但是当我尝试称呼他们时,我会收到以下错误:
> py -m gallery-dl
C:\Program Files\Python310\python.exe: No module named gallery-dl
除非我用下划线替换连字符:
> py -m gallery_dl --help
usage: __main__.py [OPTION]... URL...
General Options:
...
这与我不使用发射器并在路径中使用Python的情况大不相同,并且可以在PowerShell内部拨打Gallery -dl
,而无需:
- 准备
py -m
- 可以用下划线 - 替换连字符 - 这不太好,因为它感觉就像我在调用
- 具有
__ main __. py:
bit的原始功能 -对了。
这是预期和适当的行为,还是[我在做 /做我做的]错误?
I'm using the Python launcher on Windows to simplify version management and avoid modifying system path.
I've successfully installed a few packages:
> py -m pip list
Package Version
------------------ ---------
Brotli 1.0.9
certifi 2021.10.8
charset-normalizer 2.0.12
gallery-dl 1.21.1
idna 3.3
mutagen 1.45.1
pip 22.0.4
pycryptodomex 3.14.1
requests 2.27.1
setuptools 58.1.0
urllib3 1.26.9
websockets 10.3
yt-dlp 2022.4.8
They're all listed under Program Files/Python310/Scripts
:
but when I try to call them I get the following error:
> py -m gallery-dl
C:\Program Files\Python310\python.exe: No module named gallery-dl
unless I replace hyphens with underscores:
> py -m gallery_dl --help
usage: __main__.py [OPTION]... URL...
General Options:
...
This is quite different from when I wasn't using the launcher and had python in PATH and could just call gallery-dl
inside Powershell without:
- prepending
py -m
- which is fine - replacing hyphens with underscores - which is less fine because it sort of feels like I'm calling a raw function
- having the
__main__.py:
bit - which doesn't feel right either.
Is this the expected and proper behavior, or [am I doing / did I do] something wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论