Skip to content

Instantly share code, notes, and snippets.

@joeblackwaslike
Last active April 13, 2025 08:44
Show Gist options
  • Save joeblackwaslike/752b26ce92e3699084e1ecfc790f74b2 to your computer and use it in GitHub Desktop.
Save joeblackwaslike/752b26ce92e3699084e1ecfc790f74b2 to your computer and use it in GitHub Desktop.
How to use python with the Cursor IDE

How to use python with the Cursor AI IDE

We are going to edit cursors settings to point to the microsoft extensions marketplace.

  1. Remove all extensions and exit Cursor.
  2. Locate your Cursor project.json file depending on your platform and open it.
    • On MacOS: /Applications/Cursor.app/Contents/Resources/app/product.json
    • On Windows: C:\Users\<user_name>\AppData\Local\Programs\cursor\resources\app\product.json
    • On Linux: /usr/lib/code/product.json
  3. Locate the object value for key extensionsGallery in the json document.

Contents of extensionsGallery key in product.json for Cursor

{
    "galleryId": "cursor",
    "serviceUrl": "https://marketplace.cursorapi.com/_apis/public/gallery",
    "itemUrl": "https://marketplace.cursorapi.com/items",
    "resourceUrlTemplate": "https://marketplace.cursorapi.com/{publisher}/{name}/{version}/{path}",
    "controlUrl": "",
    "recommendationsUrl": "",
    "nlsBaseUrl": "",
    "publisherUrl": ""
}
  1. Edit it to look like this:
{
    "galleryId": "cursor",
    "serviceUrl": "https://marketplace.visualstudio.com/_apis/public/gallery",
    "itemUrl": "https://marketplace.visualstudio.com/items",
    "resourceUrlTemplate": "https://{publisher}.vscode-unpkg.net/{publisher}/{name}/{version}/{path}",
    "controlUrl": "",
    "recommendationsUrl": "",
    "nlsBaseUrl": "",
    "publisherUrl": ""
}
  1. Reopen Cursor.app and install the following extensions:
    • ms-python.python
    • ms-python.vscode-pylance
    • ms-python.debugpy
  2. Make sure in your settings that python.languageServer is set to "Pylance"

Enjoy!

PS: you may need to goto your settings.json to remove any theme settings, because having a broken theme looks exactly like this same problem. In my case cursor had copied over my settings from vscode and they pointed to a theme that wasn't yet installed in cursor, removing and then setting the theme manually worked when I though for sure I had broken it again.

@Star9daisy
Copy link

Nice! Thank you!

@praateekmahajan
Copy link

I wonder if in new cursor releases somehting has changed since November when this was originally written, since I now see more keys, and the key extensionUrlTemplate has the same value as what @joeblackwaslike proposed for resourceUrlTemplate

  "extensionsGallery": {
    "galleryId": "cursor",
    "serviceUrl": "https://marketplace.cursorapi.com/_apis/public/gallery",
    "itemUrl": "https://marketplace.cursorapi.com/items",
    "resourceUrlTemplate": "https://marketplace.cursorapi.com/{publisher}/{name}/{version}/{path}",
    "controlUrl": "",
    "extensionUrlTemplate": "https://www.vscode-unpkg.net/_gallery/{publisher}/{name}/latest",
    "recommendationsUrl": "",
    "nlsBaseUrl": "",
    "publisherUrl": ""
  },

@joeblackwaslike
Copy link
Author

I wonder if in new cursor releases somehting has changed since November when this was originally written, since I now see more keys, and the key extensionUrlTemplate has the same value as what @joeblackwaslike proposed for resourceUrlTemplate

"extensionsGallery": {
"galleryId": "cursor",
"serviceUrl": "https://marketplace.cursorapi.com/_apis/public/gallery",
"itemUrl": "https://marketplace.cursorapi.com/items",
"resourceUrlTemplate": "https://marketplace.cursorapi.com/{publisher}/{name}/{version}/{path}",
"controlUrl": "",
"extensionUrlTemplate": "https://www.vscode-unpkg.net/_gallery/{publisher}/{name}/latest",
"recommendationsUrl": "",
"nlsBaseUrl": "",
"publisherUrl": ""
},

@praateekmahajan while it's possible, I've seen those keys too prior to my changing them. I really doubt cursor will start shipping this way because it breaks microsoft licensing terms, which is why you won't hear them suggesting what I have here.

@ntluong95
Copy link

Does this tutorial allow us to use the most recent version of Pylance?

@joeblackwaslike
Copy link
Author

Does this tutorial allow us to use the most recent version of Pylance?

@ntluong95 yes that's the point, this trick involves pointing cursor to microsofts extension marketplace so you will always get what vscode gets.

@alexsafayan
Copy link

<3

@crux888
Copy link

crux888 commented Feb 19, 2025

Amazing, thank you!

@recycletechno
Copy link

Thank you!

@Harteg
Copy link

Harteg commented Feb 28, 2025

Hm, when I open Cursor after editing the file i get: “Cursor.app” is damaged and can’t be opened. You should move it to the Bin.
Tried reinstalling cursor before editing the product.json file but same result. Ideas?

@mikicnemanja
Copy link

Thx

@ognjenantonijevic
Copy link

Does anyone know where this file is in Fedora (installed with AppImage)?

@emptytank
Copy link

Awesome, thanks so much. Worked like a charm!

@kapis
Copy link

kapis commented Mar 10, 2025

My other problem was Cursor using very old Pylance version -> old Pyright version with many bugs that are already fixed.

This was solved by editing extensionMaxVersions field in the same file. Manually updating maxVersion for each extension made Cursor install new versions of extension.

@ntluong95
Copy link

My other problem was Cursor using very old Pylance version -> old Pyright version with many bugs that are already fixed.

This was solved by editing extensionMaxVersions field in the same file. Manually updating maxVersion for each extension made Cursor install new versions of extension.

when you change the extensionMaxVersions, do you need to update extension version one by one or update to the newest one directly?

@kapis
Copy link

kapis commented Mar 10, 2025

Dunno, I've first fixed Pylance, and when it worked, fixed the rest together.

Once I've relaunched Cursor, it auto-updated all affected extensions

@ntluong95
Copy link

Dunno, I've first fixed Pylance, and when it worked, fixed the rest together.

Once I've relaunched Cursor, it auto-updated all affected extensions

What is your version of Pylance now?

@kapis
Copy link

kapis commented Mar 10, 2025

The latest, 2025.3.1

@alexwilson1
Copy link

alexwilson1 commented Mar 19, 2025

Deleting the "extensionMaxVersions" block and then restarting Cursor completely would appear to bring all extensions to the latest versions too.

@lukaemon
Copy link

works!

@MarvinYang93
Copy link

MarvinYang93 commented Mar 24, 2025

2025-03-24 20:03:04.650 [info] [Info - 8:03:04 PM] (934244) Pylance language server 2024.8.1 (pyright version 1.1.373, commit ee424479) starting 2025-03-24 20:03:04.650 [info] [Info - 8:03:04 PM] (934244) Server root directory: file:///root/.cursor-server/extensions/ms-python.vscode-pylance-2024.8.1/dist 2025-03-24 20:03:04.652 [info] [Error - 8:03:04 PM] Server initialization failed. 2025-03-24 20:03:04.652 [info] Message: Request initialize failed with message: You may install and use any number of copies of the software only with Microsoft Visual Studio, Visual Studio for Mac, Visual Studio Code, Azure DevOps, Team Foundation Server, and successor Microsoft products and services (collectively, the “Visual Studio Products and Services”) to develop and test your applications. The software is licensed, not sold. This agreement only gives you some rights to use the software. Microsoft reserves all other rights. You may not: work around any technical limitations in the software that only allow you to use it in certain ways; reverse engineer, decompile or disassemble the software, or otherwise attempt to derive the source code for the software, except and to the extent required by third party licensing terms governing use of certain open source components that may be included in the software; remove, minimize, block, or modify any notices of Microsoft or its suppliers in the software; use the software in any way that is against the law or to create or propagate malware; or share, publish, distribute, or lease the software (except for any distributable code, subject to the terms above), provide the software as a stand-alone offering for others to use, or transfer the software or this agreement to any third party.
But I still had this error and I still couldn't use pylance

@joeblackwaslike
Copy link
Author

Hm, when I open Cursor after editing the file i get: “Cursor.app” is damaged and can’t be opened. You should move it to the Bin. Tried reinstalling cursor before editing the product.json file but same result. Ideas?

This sounds like the app is protected with some kind of code signing, can you provide more context around your platform?

@lukaemon
Copy link

2025-03-24 20:03:04.650 [info] [Info - 8:03:04 PM] (934244) Pylance language server 2024.8.1 (pyright version 1.1.373, commit ee424479) starting 2025-03-24 20:03:04.650 [info] [Info - 8:03:04 PM] (934244) Server root directory: file:///root/.cursor-server/extensions/ms-python.vscode-pylance-2024.8.1/dist 2025-03-24 20:03:04.652 [info] [Error - 8:03:04 PM] Server initialization failed. 2025-03-24 20:03:04.652 [info] Message: Request initialize failed with message: You may install and use any number of copies of the software only with Microsoft Visual Studio, Visual Studio for Mac, Visual Studio Code, Azure DevOps, Team Foundation Server, and successor Microsoft products and services (collectively, the “Visual Studio Products and Services”) to develop and test your applications. The software is licensed, not sold. This agreement only gives you some rights to use the software. Microsoft reserves all other rights. You may not: work around any technical limitations in the software that only allow you to use it in certain ways; reverse engineer, decompile or disassemble the software, or otherwise attempt to derive the source code for the software, except and to the extent required by third party licensing terms governing use of certain open source components that may be included in the software; remove, minimize, block, or modify any notices of Microsoft or its suppliers in the software; use the software in any way that is against the law or to create or propagate malware; or share, publish, distribute, or lease the software (except for any distributable code, subject to the terms above), provide the software as a stand-alone offering for others to use, or transfer the software or this agreement to any third party.

但是我依然遇到了这样的错误,无法载入

update cursor app could reset product.json so msft would detect cursor using its lang server, hence the error.

@realdimas
Copy link

I’ve seen quite a few macOS-related questions about Gatekeeper and System Integrity Protection (SIP) in this thread (“Cursor.app is damaged and can’t be opened. You should move it to the Trash.”).

Below are some helpful commands:

  • Check the code signatures on Cursor.app
    codesign -v -v --deep --strict /Applications/Cursor.app

  • Re-sign Cursor.app
    codesign --force --deep --sign - /Applications/Cursor.app

  • Check for the quarantine extended attribute
    xattr -p com.apple.quarantine /Applications/Cursor.app/Contents
    Any output other than No such xattr: com.apple.quarantine indicates that the application is quarantined.

  • Remove the quarantine extended attribute
    xattr -r -d com.apple.quarantine /Applications/Cursor.app

Also, note that right-clicking (or control-clicking) on an application in Finder and selecting “Open” is not the same as double-clicking it.
Using “Open” from the context menu lets you bypass Gatekeeper’s initial refusal, typically offering a button to force the application to open.
Often, apps that were prevented from opening will also appear in System SettingsPrivacy & SecuritySecurity section with a button “Open Anyway”.

@realdimas
Copy link

I too was disappointed that the Python language server shipped with Cursor does not support the unit test coverage UI.
However, I was able to get the current versions of Python extensions (Python, Python Debugger, and Pylance) to work in Cursor.

The workaround I’m using is as follows:

  • Edit package.json to increase the maxVersion of Python-related extensions
  • Disable auto-updates for Python-related extensions
  • Manually download the extension packages (the .VSIX files)
  • Drag and drop the extensions into Cursor’s Extensions tab

Here is a script I wrote to automate the package.json patching on macOS:
https://gist.github.com/realdimas/e58723564cfada8efd93adab6efb747c

It also re-signs the app’s code signature and removes the quarantine attribute (for convenience).

Note that updating the Cursor app will reset the version of the Python extensions, so you’ll need to reapply these changes (including the extension drag-and-drop).
I found it helpful to disable Cursor auto-updates (see instructions here: https://forum.cursor.com/t/how-do-i-prevent-automatic-updating/59637/10) and update Cursor manually instead.

@PhenomenaPh
Copy link

Hi!

Thank you for this guide!
I was wondering if there is any way to turn off the rewriting of product.json after each cursor update? It’s really annoying.

@Nivg
Copy link

Nivg commented Apr 6, 2025

Hi!

Thank you for this guide! I was wondering if there is any way to turn off the rewriting of product.json after each cursor update? It’s really annoying.

I just had the same question, each update I need to redo this process, the Cursor Python language support is broken!

@realdimas
Copy link

@PhenomenaPh, @Nivg – product.json is part of Cursor package.
You are hacking the internals of the app.
Each update override it – this is expected and no known workaround exist.
Understand that you generally want & need the updated product.json.
Its just that some keys in this file needs to be modified post-update to revive python extensions.

My approach: streamline the update of product.json file (see macOS script linked above that I use) and do upgrades manually (disable automatic upgrades) so that you can take care of "maintenance" tasks on your own time without disruption.

@Nivg
Copy link

Nivg commented Apr 6, 2025

@PhenomenaPh, @Nivg – product.json is part of Cursor package. You are hacking the internals of the app. Each update override it – this is expected and no known workaround exist. Understand that you generally want & need the updated product.json. Its just that some keys in this file needs to be modified post-update to revive python extensions.

My approach: streamline the update of product.json file (see macOS script linked above that I use) and do upgrades manually (disable automatic upgrades) so that you can take care of "maintenance" tasks on your own time without disruption.

It seems that in a devcontainer, where I set my extensions (and pylance is one of them), it's ignoring it and installing the cursoer pyright one all the time, do you have any idea about this issue?

Thanks!

@realdimas
Copy link

@Nivg locally, we fix this issue by patching product.json to shift away from the Cursor extension gallery and instead point to the Microsoft extension gallery.
We also bump the extension versions to the latest.
This allows us to install current and unmodified ms-python.python (and other) extensions via locally downloaded .VSIX files that don't depend on anysphere.pyright.

None of these local fixes have any effect on remote environments.

In remote environments, Cursor (VS Code) has its own product.json file and a modified version of the ms-python.python extension which declares a dependency on Cursor's Pyright (ID: anysphere.pyright) extension.

I didn't bother automating the rewrite of the remote product.json file, nor investigating how the patched ms-python.python extension gets there.

Instead, I use this workaround once per remote environment:

  1. Download Python extensions from Microsoft extension gallery as .VSIX files (matching the remote operating system and architecture).
  2. Drag-and-drop the .VSIX files into the Extensions tab's remote section.
  3. Reload window.
  4. Uninstall the Cursor Pyright extension.

I like to keep "Auto Update" checkbox unchecked to upgrade manually via .VSIX files instead.


Below are the direct download links to the current versions of Python extensions for linux-x64 and linux-arm64 architectures:

@Nivg
Copy link

Nivg commented Apr 9, 2025

@Nivg locally, we fix this issue by patching product.json to shift away from the Cursor extension gallery and instead point to the Microsoft extension gallery. We also bump the extension versions to the latest. This allows us to install current and unmodified ms-python.python (and other) extensions via locally downloaded .VSIX files that don't depend on anysphere.pyright.

None of these local fixes have any effect on remote environments.

In remote environments, Cursor (VS Code) has its own product.json file and a modified version of the ms-python.python extension which declares a dependency on Cursor's Pyright (ID: anysphere.pyright) extension.

I didn't bother automating the rewrite of the remote product.json file, nor investigating how the patched ms-python.python extension gets there.

Instead, I use this workaround once per remote environment:

  1. Download Python extensions from Microsoft extension gallery as .VSIX files (matching the remote operating system and architecture).
  2. Drag-and-drop the .VSIX files into the Extensions tab's remote section.
  3. Reload window.
  4. Uninstall the Cursor Pyright extension.

I like to keep "Auto Update" checkbox unchecked to upgrade manually via .VSIX files instead.

Below are the direct download links to the current versions of Python extensions for linux-x64 and linux-arm64 architectures:

Wow, many thanks for the very detailed explanation!

I wonder if with the new Microsoft enforcement rollout for using their extensions only in the official vscode, those workarounds won’t work anymore as well…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment