JuPyter(IPython) Notebooks中使用pip安装Python的模块
刚开始接触JuPyter Notebook的时候觉得这是个不错的写技术博客的工具,可以很直观的把代码和结果结合在一起。于是想着趁热打铁,把前段时间学习PyQuery的经验总结一下分享出来。可是IPython里默认没有PyQuery模块,而且不能直接运行pip去安装。查了一下*之后终于找到了下面的代码,运行之后就可以在JuPyter Notebook里使用PyQuery了。
import pip
def install(package):
pip.main(['install', package])
install('pyquery')
输出:
Requirement already satisfied (use --upgrade to upgrade): pyquery in c:\users\alvin\anaconda3\lib\site-packages
Requirement already satisfied (use --upgrade to upgrade): lxml>=2.1 in c:\users\alvin\anaconda3\lib\site-packages (from pyquery)
Requirement already satisfied (use --upgrade to upgrade): cssselect>0.7.9 in c:\users\alvin\anaconda3\lib\site-packages (from pyquery)
You are using pip version 7.1.2, however version 8.0.2 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.