Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if Python has sqlite3 is installed before attempting to install ipykernel #5149

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

juliasilge
Copy link
Contributor

Addresses #4698

Currently the message says this if your Python doesn't have sqlite3 there:

Screenshot 2024-10-23 at 4 08 08 PM

Thoughts or feedback? We believe this is most likely to happen on Linux when you are missing a sysreq.

QA Notes

To confirm this is working as expected, you need two Python envs:

  • Make one new Python env that is "normal", i.e. has the built-in sqlite3 module, but doesn't have ipykernel installed (perhaps via pyenv virtualenv). You should be able to choose this env via "Python: Select Interpreter", agree to the ipykernel installation, and see the ipykernel installation succeed. ✅
  • Make one new Python env that has ✨ problems ✨ i.e. does not have the built-in sqlite3 module. The only way I could find to do this is to delete it: first find where it is for the Python you are about to destroy and then delete it. Now choose this Python env via "Python: Select Interpreter" and see the message telling you that you need sqlite3. 🚫

@@ -23,6 +23,7 @@ export class ProductService implements IProductService {
this.ProductTypes.set(Product.python, ProductType.Python);
// --- Start Positron ---
this.ProductTypes.set(Product.fastapiCli, ProductType.DataScience);
this.ProductTypes.set(Product.sqlite3, ProductType.DataScience);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not really a data science package, but it is most like that given the current options in ProductType. I did try adding a new type but then we would need to make an installer for it and that doesn't seem important, given that we can't install the missing system requirement for people in a straightforward way.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC the names are misleading. This looks like the right place.

@juliasilge juliasilge marked this pull request as ready for review October 24, 2024 03:53
@juliasilge juliasilge requested a review from seeM October 24, 2024 03:53
Copy link
Contributor

@seeM seeM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a new Python 3.9.18 venv and moved the sqlite3 module folder to sqlite-bak, then tried to start it. In my case, it showed the ipykernel install prompt and when I accepted that, it showed an error:

image

Not sure if I misread the instructions.

@@ -303,6 +303,8 @@ export function translateProductToModule(product: Product): string {
// --- Start Positron ---
case Product.fastapiCli:
return 'fastapi_cli';
case Product.sqlite3:
return '_sqlite3';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this correct?

Suggested change
return '_sqlite3';
return 'sqlite3';

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what generates the original error:
https://github.com/python/cpython/blob/main/Lib/sqlite3/dbapi2.py#L27

from _sqlite3 import *

@@ -23,6 +23,7 @@ export class ProductService implements IProductService {
this.ProductTypes.set(Product.python, ProductType.Python);
// --- Start Positron ---
this.ProductTypes.set(Product.fastapiCli, ProductType.DataScience);
this.ProductTypes.set(Product.sqlite3, ProductType.DataScience);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC the names are misleading. This looks like the right place.

@juliasilge
Copy link
Contributor Author

I just kicked off a release build here so we can have folks with easy access to a Linux machine to test it out. To test it out, you will need:

  • Linux machine with no sqlite system library installed
  • Install pyenv and then a Python version (you should see "WARNING: The Python sqlite3 extension was not compiled. Missing the SQLite3 lib?" during this installation)
  • Open up Positron and try to start that pyenv Python

@petetronic
Copy link
Collaborator

petetronic commented Oct 25, 2024

Using Fedora 40 desktop, I was able to see the new warning.

  • I uninstalled python 3.11.10 using pyenv
  • I ensured sqlite3 was not installed on Fedora
  • I re-installed python 3.11.10 using pyenv and confirmed I saw the expected warning during installation

WARNING: The Python sqlite3 extension was not compiled. Missing the SQLite3 lib?

  • I installed the custom Positron prerelease build .rpm that @juliasilge listed above
  • I started a Python 3.11.10 interpreter
  • It showed the expected improved error in the Positron Console:

The Python sqlite3 extension is required but not installed for interpreter: Python 3.11.10 64-bit ('3.11.10'). Missing the SQLite3 lib?

To confirm the happy path:

  • I ran sudo dnf install sqlite-devel
  • I uninstalled Python 3.11.10 with pyenv
  • I re-installed Python 3.11.10 with pyenv, and noted there was no warning about sqlite3
  • I restarted Positron from above, and started a Python 3.10.11 interpreter
  • It prompted me to install ipykernel, which I accepted
  • I was able to use the Positron Console with this Python interpreter successfully

Note that sqlite by itself was not enough, it needed to be the sqlite-devel package so that the Python module _sqlite3 could be compiled during installation. We could note the distinction in our installation guide if it's too much detail to customize this message per platform. We could perhaps refer people to Positron's installation guide too.

@juliasilge
Copy link
Contributor Author

juliasilge commented Oct 25, 2024

I added this info to our docs here: posit-dev/positron-website#11

What do you think would be the most clear error message? Maybe a slight edit such as:

The Python sqlite3 extension is required but not installed for interpreter: ${this.interpreter?.displayName}. Missing the system library for SQLite?

@juliasilge juliasilge requested a review from seeM October 25, 2024 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants