- Python Data Science Essentials
- Alberto Boschetti Luca Massaron
- 221字
- 2021-08-13 15:19:36
Installing packages directly from Jupyter Notebooks
Jupyter magic commands are really efficient in accomplishing different tasks, but you may sometimes find it difficult to achieve installing new packages during a Jupyter session (and it will happen often since you are using different environments based on conda or env). As Jake VanderPlas explained in his blog post Installing Python Packages from a Jupyter Notebook (https://jakevdp.github.io/blog/2017/12/05/installing-python-packages-from-jupyter/), it is a matter of fact that Jupyter kernels are different from the shell you started from, that is, you may be upgrading a wrong environment when you issue magic commands such as !pip install numpy or !conda install --yes numpy.
The correct approach for installing, let's say, NumPy, using pip under a Jupyter Notebook is by creating a cell like this:
In: import sys
!"{sys.executable}" -m pip install numpy
Instead, if you want to use conda, this is the cell you have to create:
In: import sys
!conda install --yes --prefix "{sys.prefix}" numpy
Just replace numpy with any package you would like to install and then run, and the installation is guaranteed to succeed.
- 嵌入式系統(tǒng)應(yīng)用
- Cinema 4D R13 Cookbook
- 西門子PLC與InTouch綜合應(yīng)用
- 智能工業(yè)報警系統(tǒng)
- PyTorch Deep Learning Hands-On
- Implementing Oracle API Platform Cloud Service
- Android游戲開發(fā)案例與關(guān)鍵技術(shù)
- Prometheus監(jiān)控實(shí)戰(zhàn)
- Windows Server 2008 R2活動目錄內(nèi)幕
- 單片機(jī)技術(shù)項目化原理與實(shí)訓(xùn)
- 探索中國物聯(lián)網(wǎng)之路
- 仿龜機(jī)器人的設(shè)計與制作
- GAN實(shí)戰(zhàn)
- 從零開始學(xué)Visual C++
- DevOps:Puppet,Docker,and Kubernetes