Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Python

List โมดูล Python ที่ติดตั้ง Local (หลายวิธี)

หลายวิธีดูโมดูลที่ติดตั้งในเครื่อง

1. Python Shell: help('modules')

>>> help('modules')
Please wait...
BaseHTTPServer  brain_nose  markupbase  stat  ...

2. Command Line: pip freeze (Standard)

$ pip freeze
asn1crypto==0.22.0
astroid==1.5.2
...

3. pip list (Readable Format, pip 1.3+)

$ pip list
asn1crypto (0.22.0)
astroid (1.5.2)
attrs (16.3.0)
...

4. pip list --outdated / --local / --user

$ pip list --outdated      # แสดงที่มี Version ใหม่
$ pip list --local         # แค่ Local (ไม่รวม System)
$ pip list --user          # แค่ User Site-packages

5. ใน Code: pkgutil.iter_modules

>>> from pkgutil import iter_modules
>>> [name for _, name, _ in iter_modules()][:10]