How to install third-party libraries in PyCharm?
This tutorial is written by: Daxia (AhcaoZhu) .
1. Before installing, how do you know which libraries your system has installed?
There are several known ways to know which libraries or modules are installed on your system. Listed below, in fact, you know one of them is enough.
1. In the window's resource manager, find the Python installation directory
Under <installation directory>\Lib\, there are already installed libraries.
2. In the PyCharm integrated editor
1) Open the console. Type the command help()
if you can’t find the console, see the picture below (1)
2) Then, type: modules
3) You may get the following list indicating the libraries or modules that your system has installed.
Please note: Because the system version installed on each machine and the initialization situation are different, the following is just an example. That's roughly what it looks like on your machine.
For the modules listed above, you can continue to type the module name directly at the help> prompt to get very detailed help for the module, but it is explained in English.
3. In the settings
Open
设置
1) Open method one: Menu文件
→设置
. Or, as shown in the figure below:
2) Opening method 2:
After opening, find the project interpreter. In the list on the right, the currently installed modules and the latest modules of each module are clearly listed. Do you need to upgrade? (You can decide to upgrade automatically, not upgrade, or manually upgrade)
2. How to install the module
Basically corresponding to the installation module found above, the installation methods usually have the following types:
1. When writing code in the IDE, we directly import the module, whether it is installed or not:
import matplotlib
As shown in the picture above, when this module is not installed, the instant help of the system will display a small red light, and when the mouse hovers over the code, it will pop up 安装软件包matplotlib
this prompt.
At this time, we can directly click on it to install it.
2. 设置
Install in
For the method of opening
设置
, see first and 3 above).
In this interface, you can search for the module name and install it. Or:
When a module is not the latest version and you want to upgrade to the latest version, you can also directly click the link on the right in the list to upgrade and install directly.
3. 软件包
Install in
As shown in the figure below: follow the sequence shown in the illustrations, first search, view the module description and help, and finally click 4) to install.
4. Install 终端
under :
The method of opening the terminal: (choose one)
1) SelectPython控制台
the terminal at the bottom of the PyCharm IDE window
2) Under Windows, press the WIN+R key (or任务栏
→开始菜单
,搜索程序和文件
entercmd
Enter
In the terminal opened above, enter:
pip install <模块名> 回车
This is the most professional method, and of course the most complicated.
The pip command, without parameters, will echo the help of the command line parameters. See.
In addition, the advantage of using pip is that it can write batch processing, plan scheduling and remote installation.
3. How do I know which modules need to be installed? Which modules do what?
An important principle is to install these related modules when a certain aspect of research or development is required;
in the software package introduced above, try to enter the name of the module you imagined, and a list will appear, click the one you are interested in Name, the version, module function introduction and other information will appear on the right. You spend a little time getting to know it first, rather than rushing to install it. Maybe there are better options.
Below I list the common modules introduced in the official V3.7.8 version and their classifications for reference. (Of course it may have outdated content)
Python standard library
Python语言参考描述了 Python 语言的具体语法和语义,这份库参考则介绍了与 Python 一同发行的标准库。它还描述了通常包含在 Python 发行版中的一些可选组件。
> Python 标准库非常庞大,所提供的组件涉及范围十分广泛,正如以下内容目录所显示的。这个库包含了多个内置模块 (以 C 编写),Python 程序员必须依靠它们来实现系统级功能,例如文件 I/O,此外还有大量以 Python 编写的模块,提供了日常编程中许多问题的标准解决方案。其中有些模块经过专门设计,通过将特定平台功能抽象化为平台中立的 API 来鼓励和加强 Python 程序的可移植性。
> Windows 版本的 Python 安装程序通常包含整个标准库,往往还包含许多额外组件。对于类 Unix 操作系统,Python 通常会分成一系列的软件包,因此可能需要使用操作系统所提供的包管理工具来获取部分或全部可选组件。
> 在这个标准库以外还存在**成千上万**并且不断增加的其他组件 (从单独的程序、模块、软件包直到完整的应用开发框架),访问 Python 包索引 即可获取这些第三方包。
- overview
- usability notes
- built-in function
- built-in constants
constants added by the site module - Built-in types
Logical value detection
Boolean operations—and, or, not
comparison operations
Numeric types—int, float, complex
iterator types
Sequence types—list, tuple, range
Text sequence types—str
Binary sequence types—bytes, bytearray, memoryview
collection types — set, frozenset
mapping types — dict
context manager types
other built-in types
special attributes - Built-in Exceptions
Base Classes
Concrete Exceptions
Warnings Exception
Hierarchy - Text processing services
string — common string manipulation
re — regular expression manipulation
difflib — aids for computing differences
textwrap — text wrapping and padding
unicodedata — Unicode database
stringprep — Internet string preparation
readline — GNU readline interface
rlcompleter — GNU readline's Completion function - Binary data service
struct — Interpret byte strings as packed binary data
codecs — Codec registration and related base classes - Data type
datetime — basic date and time type
calendar — calendar related functions
collections — container data type
collections.abc — abstract base class of container
heapq — heap queue algorithm
bisect — array binary search algorithm
array — efficient numerical array
weakref — weak reference
types — dynamic type creation and built-in type names
copy — shallow and deep copy operations
pprint — data beautification output
reprlib — another repr() implementation
enum — enumerated type support - Numbers and mathematics module
numbers — abstract base class of numbers
math — mathematical functions
cmath — mathematical functions about complex numbers
decimal — decimal fixed-point and floating-point operations
fractions — fraction
random — generate pseudo-random numbers
statistics — mathematical statistics functions - Functional programming module
itertools — functions to create iterators for efficient looping
functools — higher-order functions and operations on callable objects
operator — standard operator replacement functions - file and directory access
pathlib — object-oriented file system paths
os.path — common path operations
fileinput — iterate over lines from multiple input streams
stat — parse stat() results
filecmp — compare files and directories
tempfile — generate temporary files and directories
glob — Unix-style pathname pattern extensions
fnmatch — Unix filename pattern matching
linecache — random reading and writing of text lines
shutil — high-level file manipulation
macpath — Mac OS 9 path manipulation functions - data persistence
pickle - Python object serialization
copyreg - note pickle support functions
shelve - Python object persistence
marshal - internal Python object serialization
dbm - Unix "database" interface
sqlite3 - SQLite database DB-API 2.0 interface module - data compression and archiving
zlib — gzip-compatible compression
gzip — support for gzip format
bz2 — support for bzip2 compression algorithm
lzma — compress
zipfile with LZMA algorithm
tarfile — read and write tar archive files - File Format
csv — read and write CSV files
configparser — config file parser
netrc — netrc file processing
xdrlib — encode and decode XDR data
plistlib — generate and parse Mac OS X .plist files - Cryptographic services
hashlib — secure hashing and message digests
hmac — key-based message authentication
secrets — generate secure random numbers for managing passwords - General operating system service
os — operating system interface module
io — core tool for processing streams
time — time access and conversion
argparse — command line options, arguments and subcommand parser
getopt — C-style command line option parser
module logging — Python’s logging tool
logging.config — logging configuration
logging.handlers — log handling
getpass — portable password input tool
curses — handling of terminal character cell displays
curses.textpad — text input control for curses programs
curses.ascii — for ASCII characters tool for
curses.panel — the panel stack extension of curses
platform — to obtain the identification data of the underlying platform
errno — the standard errno system symbol
ctypes — the foreign function library for Python - Concurrent execution
threading — thread-based parallel
multiprocessing — process-based parallel
concurrent package
concurrent.futures — start parallel tasks
subprocess — subprocess management
sched — event scheduler
queue — a synchronous queue class
_thread — underlying multithreading API
_dummy_thread — _thread Replacement module
dummy_threading — drop-in replacement for the threading module.
contextvars context variables - Context variables
Manual context management
asyncio support
Network and interprocess communication
asyncio — asynchronous I/O
socket — underlying network interface
ssl — TLS/SSL encapsulation of socket objects
select — Waiting for I/O completion
selectors — advanced I/O multiplexing library
asyncore — asynchronous socket handler
asynchat — asynchronous socket command/response handler
signal — set asynchronous event handler
mmap — memory mapped file support - Internet data processing
email — email and MIME processing packages
json — JSON encoding and decoding
mailcap — Mailcap file processing
mailbox — manipulating mailboxes in multiple formats
mimetypes — mapping folders to MIME types
base64 — Base16, Base32, Base64, Base85 data encoding
binhex — encode and decode binhex4 files
binascii — convert between binary and ASCII
quopri — encode and decode MIME-transcoded printable data
uu — encode and decode uuencode files - Structured markup processing tools
html — hypertext markup language support
html.parser — simple HTML and XHTML parser
html.entities — definitions of HTML general entities - XML processing module
xml.etree.ElementTree — ElementTree XML API
xml.dom — Document Object Model API
xml.dom.minidom — minimal DOM implementation
xml.dom.pulldom — support for building partial DOM trees
xml.sax — support for SAX2 parsers
xml.sax.handler — base class for SAX handlers
xml.sax.saxutils — SAX toolset
xml.sax.xmlreader — interface for XML parsers
xml.parsers.expat — fast XML parsing using Expat - internet protocol and support
webbrowser — convenient web browser controller
cgi — Common Gateway Interface support
cgitb — traceback manager for CGI scripts
wsgiref — implementation of WSGI tools and references
urllib — URL handling module
urllib.request — for opening URLs Extensible library
for urllib.response — Response class used by urllib
urllib.parse for parsing URLs
urllib.error — exception class raised by urllib.request
urllib.robotparser — robots.txt parser
http — HTTP module
http.client — HTTP Protocol client
ftplib — FTP protocol client
poplib — POP3 protocol client imaplib — IMAP4 protocol client nntplib — NNTP
protocol client smtplib — SMTP protocol client smtpd — SMTP server telnetlib — Telnet client uuid — UUID object defined by RFC 4122 socketserver — framework for web servers http.server — HTTP server
http.cookies — HTTP state management
http.cookiejar — HTTP client cookie handling
xmlrpc — XMLRPC server and client modules
xmlrpc.client — XML-RPC client access
xmlrpc.server — basic XML-RPC server
ipaddress — IPv4/IPv6 operation library - Multimedia service
audioop — process original audio data
aifc — read and write AIFF and AIFC files
sunau — read and write Sun AU files
wave — read and write WAV format files
chunk — read IFF block data
colorsys — convert between color systems
imghdr — guess image type
sndhdr — guess the type of sound file
ossaudiodev — access OSS compatible audio devices - Internationalization
gettext — multilingual internationalization service
locale — internationalization service - Program framework
turtle — turtle drawing
cmd — line-oriented command interpreter supported
shlex — simple word meaning analysis
Tk GUI
tkinter — Python interface to Tcl/Tk
tkinter.ttk — Tk theme widget
tkinter.tix — TK Extension package
tkinter.scrolledtext — scrolling text control
IDLE
other GUI packages - Development tools
typing — type annotation support
pydoc — document generator and online help system
doctest — Python example for testing interactivity
unittest — unit test framework
unittest.mock — mock object library
unittest.mock Getting Started Guide
2to3 — automatically convert Python 2 code to Python 3 code
test — Python regression testing package
test.support — Utilities for the Python test suite
test.support.script_helper — Utilities for the Python execution tests - Debugging and Analysis
bdb — Debugger framework
faulthandler — Dumps Python trace information
pdb — Debugger for Python - Python profiler
timeit — measure execution time of small code snippets
trace — trace Python statement execution
tracemalloc — trace memory allocation - Software packaging and distribution
distutils — building and installing Python modules
ensurepip — Bootstrapping the pip installer
venv — creating virtual environments
zipapp — managing executable Python zip packages - Python runtime service
sys — system-related parameters and functions
sysconfig — Provide access to Python's configuration information
builtins — built-in objects
__main__
— top-level scripting environment
warnings — control of warning information
dataclasses — data class contextlib — tool abc
provided for the context of the with statement
— abstract base class
atexit — exit handler
traceback — print or retrieve stack traceback
__future__
— Future statement definition
gc — garbage collector interface
inspect — inspection object
site — site-specific configuration hook
custom Python interpreter
code — interpreter base class
codeop — Compile Python code - import module
zipimport — import module from Zip archive
pkgutil — package extension module tool
modulefinder — find modules used by scripts
runpy — find and execute Python modules
importlib — implementation of import - Python language service
parser — access to Python parse tree
ast — abstract syntax tree
symtable — access to compiler’s symbol table
symbol — constant token used with Python parse tree — constant keyword
used with Python parse tree — check Python keyword tokenize – tag parser tabnanny for Python code — fuzzy indentation detection pyclbr — Python module browser support py_compile — compile Python source files compileall — Byte-compile Python libraries dis — Python bytecode disassembler pickletools — pickle developer tools set - Miscellaneous services
formatter - general format output
Windows system related modules
msilib - Read and write Microsoft Installer files
msvcrt - useful routines from MS VC++ runtime
winreg - Windows registry access
winsound - sound playback interface for Windows systems - Unix-specific services
posix — the most common POSIX system call
pwd — user password database
spwd — shadow password library
grp — group database
crypt — function for checking Unix passwords
termios — POSIX-style tty control
tty — terminal control function
pty — pseudo Terminal tool
fcntl - system calls fcntl and ioctl
pipes - terminal pipe interface
resource - resource usage information
nis - Sun's NIS (Yellow Pages) interface
Unix syslog library routines - The superseded module
optparse — the parser's command-line option
imp — is accessed internally by code import. - Undocumented modules
- platform specific modules