Python安裝、解除安裝第三方模組
阿新 • • 發佈:2018-12-13
pip command ModuleName
- command:用於指定要執行的命令(
install:
安裝,uninstall:
解除安裝) - ModuleName:需要安裝的模組名稱
示例:
安裝第三方模組numpy
模組(用於科學計算):
C:\Users> pip install numpy Collecting numpy Downloading https://files.pythonhosted.org/packages/96/d6/53a59338c613e0c3ec7e3052bbf068a5457a005a5f7ad4ae005167c3597e/numpy-1.15.2-cp37-none-win_amd64.whl (13.5MB) 100% |████████████████████████████████| 13.5MB 1.3MB/s Installing collected packages: numpy Successfully installed numpy-1.15.2
解除安裝numpy
模組:
C:\Users> pip uninstall numpy
Uninstalling numpy-1.15.2:
Would remove:
d:\python\lib\site-packages\numpy-1.15.2.dist-info\*
d:\python\lib\site-packages\numpy\*
d:\python\scripts\f2py.py
Proceed (y/n)? y
Successfully uninstalled numpy-1.15.2
多學兩招
- 如果想要檢視Python中都有哪些模組(包括標準模組和第三方模組),可以在IDE中輸入以下命令
print(help('modules')) 執行結果: Please wait a moment while I gather a list of all available modules... Demo _thread getpass secrets Demo2 _threading_local gettext select Demo3 _tkinter glob selectors Demo4 _tracemalloc gzip setuptools __future__ _warnings hashlib shelve _abc _weakref heapq shlex _ast _weakrefset hmac shutil _asyncio _winapi html signal _bisect abc http site _blake2 aifc idlelib sitecustomize _bootlocale antigravity imaplib smtpd _bz2 argparse imghdr smtplib _codecs array imp sndhdr _codecs_cn ast importlib socket _codecs_hk asynchat inspect socketserver _codecs_iso2022 asyncio io sqlite3 _codecs_jp asyncore ipaddress sre_compile _codecs_kr atexit itertools sre_constants _codecs_tw audioop json sre_parse _collections backend_interagg keyword ssl _collections_abc base64 lib2to3 stat _compat_pickle bdb linecache statistics _compression binascii locale string _contextvars binhex logging stringprep _csv bisect lzma struct _ctypes builtins macpath subprocess _ctypes_test bz2 mailbox sunau _datetime cProfile mailcap symbol _decimal calendar marshal symtable _distutils_findvs cgi math sys _dummy_thread cgitb mimetypes sysconfig _elementtree chunk mmap tabnanny _functools cmath modulefinder tarfile _hashlib cmd msilib telnetlib _heapq code msvcrt tempfile _imp codecs multiprocessing test _io codeop netrc textwrap _json collections nntplib this _locale colorsys nt threading _lsprof compileall ntpath time _lzma concurrent nturl2path timeit _markupbase configparser numbers tkinter _md5 contextlib opcode token _msi contextvars operator tokenize _multibytecodec copy optparse trace _multiprocessing copyreg os traceback _opcode crypt parser tracemalloc _operator csv pathlib tty _osx_support ctypes pdb turtle _overlapped curses pickle turtledemo _pickle dataclasses pickletools types _py_abc datetime pip typing _pydecimal dbm pipes unicodedata _pyio decimal pkg_resources unittest _queue difflib pkgutil urllib _random dis platform uu _sha1 distutils plistlib uuid _sha256 doctest poplib venv _sha3 dummy_threading posixpath warnings _sha512 easy_install pprint wave _signal email profile weakref _sitebuiltins encodings pstats webbrowser _socket ensurepip pty winreg _sqlite3 enum py_compile winsound _sre errno pyclbr wsgiref _ssl faulthandler pydoc xdrlib _stat filecmp pydoc_data xml _string fileinput pyexpat xmlrpc _strptime fnmatch queue xxsubtype _struct formatter quopri zipapp _symtable fractions random zipfile _testbuffer ftplib re zipimport _testcapi functools reprlib zlib _testconsole gc rlcompleter _testimportmultiple genericpath runpy _testmultiphase getopt sched Enter any module name to get more help. Or, type "modules spam" to search for modules whose name or summary contain the string "spam". None
隨著時間的過度,結果可能不一樣(官方可能進行,增、刪、改)
- 檢視本機已安裝的第三方模組,可以在命令視窗(cmd)中輸入
pip list
命令將會展示已安裝的所有模組:
C:\Users> pip list
Package Version
---------- -------
pip 18.0
setuptools 39.0.1