(1)打开cmd后,可以直接执行python命令(推荐)。
python -V 显示python版本
python -h 显示python所有可用命令
pip官网:https://pip.pypa.io/en/stable/
python -m pip install matplotlib --default-timeout=1000 下载安装matplotlib到全局,位置在你的python安装目录的Lib\site-packages下,所有工程可使用,--default-timeout=1000适合响应速度的模块存储服务器
python -m pip unstall matplotlib 卸载matplotlib
python -m pip list 查看已经安装的模块
python -m pip install --upgrade pip 升级pip
关于python2.7:
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Python 2.7支持到2020年月1日。更新pip后若你是Python2版本,会有此提示。
python -m pip 显示pip和python所有可用命令
Usage:
C:\Python27\python.exe -m pip <command> [options]
Commands:
install Install packages.
download Download packages.
uninstall Uninstall packages.
freeze Output installed packages in requirements format.
list List installed packages.
show Show information about installed packages.
check Verify installed packages have compatible dependencies.
config Manage local and global configuration.
search Search PyPI for packages.
wheel Build wheels from your requirements.
hash Compute hashes of package archives.
completion A helper command used for command completion.
help Show help for commands.
General Options:
-h, --help Show help.
--isolated Run pip in an isolated mode, ignoring
environment variables and user configuration.
-v, --verbose Give more output. Option is additive, and can be
used up to 3 times.
-V, --version Show version and exit.
-q, --quiet Give less output. Option is additive, and can be
used up to 3 times (corresponding to WARNING,
ERROR, and CRITICAL logging levels).
--log <path> Path to a verbose appending log.
--proxy <proxy> Specify a proxy in the form
[user:passwd@]proxy.server:port.
--retries <retries> Maximum number of retries each connection should
attempt (default 5 times).
--timeout <sec> Set the socket timeout (default 15 seconds).
--exists-action <action> Default action when a path already exists:
(s)witch, (i)gnore, (w)ipe, (b)ackup, (a)bort).
--trusted-host <hostname> Mark this host as trusted, even though it does
not have valid or any HTTPS.
--cert <path> Path to alternate CA bundle.
--client-cert <path> Path to SSL client certificate, a single file
containing the private key and the certificate
in PEM format.
--cache-dir <dir> Store the cache data in <dir>.
--no-cache-dir Disable the cache.
--disable-pip-version-check
Don't periodically check PyPI to determine
whether a new version of pip is available for
download. Implied with --no-index.
--no-color Suppress colored output
(其他可用操作,不推荐)
(2)cd到python安装目录的python.exe所在位置,或者不用cd,直接将python.exe拖拽到cmd,打开后可import Test.py,导入python已有的py文件,执行方法,查看已有的变量。
(3)cd到pycharm工程创建目录的venv\Scripts\所在位置,输入python后Enter,或者不用cd,直接将python.exe拖拽到cmd,Enter后可import Test.py,导入你自己写的py文件,执行你写的方法,查看已创建的变量。
(4)python安装目录\Scripts下有pip.exe,将pip.exe拖拽到cmd,再跟上install matplotlib --default-timeout=1000等命令,也可以执行pip相关操作,是全局性质的。
(5)pycharm工程创建目录的venv\Scripts下也有pip.exe,将pip.exe拖拽到cmd,再跟上install matplotlib --default-timeout=1000等命令,也可以执行pip相关操作,是本工程性质的,cd到工程目录,执行python,import 自己的py文件,此py文件需在venv下,否则无法识别,此时的open()文件操作,需用绝对路径,在pycharm中执行仍然可以用相对路径。此下载安装相当于在pycharm-Settings-Plugins中安装,但可以避免部分下载相关的代码错误和超时异常。