Pylance/Pyright can't resolve termcolor module in untrusted mode #4491
Replies: 6 comments 1 reply
-
I couldn't repro it, did you select your interpreter to the environment you installed the Please also add the output window logs, see https://github.com/microsoft/pylance-release/blob/main/TROUBLESHOOTING.md#filing-an-issue. Thanks! |
Beta Was this translation helpful? Give feedback.
-
I found the problem. It's weird, but Pylance resolved the above import once I trusted the workspace containing my Python script; it could not do this in Restricted mode. I don't understand this behavior. |
Beta Was this translation helpful? Give feedback.
-
This is because the workspace has to be trusted in order for us to get the sys.paths (we run your python interpreter in the background). I wonder if we could try and default the sys paths when the workspace isn't trusted based on say the path to the python executable. |
Beta Was this translation helpful? Give feedback.
-
OK, but what's really puzzling was that the import Pylance couldn't resolve in Restricted mode was only one of three in my script: it also imported from Is this because |
Beta Was this translation helpful? Give feedback.
-
Yep that's exactly why. The builtin libraries for Python are always found. |
Beta Was this translation helpful? Give feedback.
-
Moving this issue to discussion as an enhancement request for comments and upvotes. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Pylance throws
Import "termcolor" could not be resolved Pylance(reportMissingImports)
in response tofrom termcolor import cprint
, using the Python 3.11.4 interpreter. However, the code works fine under both Windows 10 and Ubuntu Linux 23.04, and termcolor is a perfectly valid module, as far as I know (currently at v. 2.3.0).Any idea why the lookup is failing? I note that
pip
has no trouble resolving it...Beta Was this translation helpful? Give feedback.
All reactions