question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

!pip not installing packages as expected

See original GitHub issue

I recently installed Python 3.9.6 from python.org and tried to run notebook against this interpreter but ran into a couple of issues.

Problem

  • Install Python 3.9.6, which was not added to the PATH
  • Open a notebook, Python 3.9.6 is listed in kernel list, select this kernel
  • Run import pandas as pd, it prompts to ask to install ipykernel
  • After ipykernel is installed, rerun the cell, we get error “pandas is missing”
  • Insert a new cell, run !pip install pandas, it works but it installs the pandas package to python 2.7 as that the interpreter in the PATH

image

Proposal

The underling problem is the disconnect between Python active interpreter, Jupyter kernel, and the python interpreter in the PATH. If users are using pyenv, venv, or conda, the extension will activate the environment, which will set up the environment properly, however we don’t have such thing for the vanilla Python interpreter.

We should probably

  • Show a warning for !pip if the pip in the PATH is not the one in the interpreter behind the selected kernel
  • Automatically add the pip from the interpreter of the selected kernel to the PATH temporarily

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
rchiodocommented, Jul 28, 2021

Personally I think we should put up an error if the user has !pip or !conda as they don’t do what the user expects.

0reactions
DonJayamannecommented, Nov 5, 2021

Suggestion:

  • Add a diagnostic error for usage of !pip and recommend using %pip or %conda if its a conda environment.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Pip Install not installing into correct directory? - Stack Overflow
From the comments to the original question, it seems that you have multiple versions of python installed and that pip just goes to...
Read more >
pip not installing packages as expected · Issue #6864 - GitHub
I recently installed Python 3.9.6 from python.org and tried to run notebook against this interpreter but ran into a couple of issues.
Read more >
Installing Packages - Python Packaging User Guide - Python.org
Run python get-pip.py . 2 This will install or upgrade pip. Additionally, it will install setuptools and wheel if they're not installed already....
Read more >
How to install and use Pip3 - ActiveState
Install Pip3. pip3 is the official package manager and pip command for Python 3. It enables the installation and management of third party ......
Read more >
Pip Command Not Found on Windows: A Guide | Built In
A “pip: command not found” error occurs when you fail to properly install the package installer for Python (pip) needed to run Python...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found