WARNING: Running pip install with root privileges is generally not a good idea. Try pip3 install --user
instead.
Requirement already satisfied: pexpect in /usr/lib/python3.6/site-packages
当你通过 pip3 install pexpect
安装pexpect之后,发现启动python脚本还是现实pexpect模块找不到,原因是因为你运行的版本不对。
比如我出现问题时候运行的是python3 pexpect_test.py
,提示ModuleNotFoundError: No module named 'pexpect'
,
这个时候你可以执行pip3 show pexpect
,找到pexpect的路径,我这里显示Name: pexpect Version: 4.8.0 Summary: Pexpect allows easy control of interactive console applications. Home-page: https://pexpect.readthedocs.io/ Author: Noah Spurrier; Thomas Kluyver; Jeff Quast Author-email: noah@noah.org, thomas@kluyver.me.uk, contact@jeffquast.com License: ISC license Location: /usr/local/lib/**python3.6**/site-packages Requires: ptyprocess
现在运行python文件的时候其实应该是python**3.6** pexpect_test.py
这里需要注意的是pip(n) ,包括还有其他的python命令,明明你安装了模块但是就是提示没有或者找不到,就是因为pip后面要跟上你的python版本数字