Giter Site home page Giter Site logo

site-packages path issue about pyright HOT 3 CLOSED

microsoft avatar microsoft commented on May 22, 2024
site-packages path issue

from pyright.

Comments (3)

erictraut avatar erictraut commented on May 22, 2024 1

Ah, it looks like you've installed two python environments (3.6 and 3.7) into the same virtual environment. Pyright found "python3.6" because that's the first that was returned by the file system. The whole purpose of virtual environments is to isolate different python installations, so I think it's considered an error to install two python environments in the same venv. If you really need two versions, you should create two parallel venvs (e.g. "dev36" and "dev37").

from pyright.

erictraut avatar erictraut commented on May 22, 2024

It looks like the current code in Pyright might fail under Windows, but that doesn't explain the problem you're seeing since you're on MacOS. I think it's a configuration issue in your case. You need to tell Pyright two pieces of information:
venvPath: The directory that contains your virtual environments (in your case, ~/.venv)
venv: The virtual environment you want to use (in your case, "dev")
You can specify both of these in the pyrightconfig.json file, but you can't use shell notation ~, so you'd need to expand the venvPath manually (e.g. "/Users/rrelict/.venv"). You can also specify the venvPath in your VS Code settings, and Pyright will pick it up from there.

from pyright.

rrelict avatar rrelict commented on May 22, 2024

Eric, thanks for the datails.

My pyrightconfig.json seems correct:

{
    "venvPath": "/Users/rrelict/.venv", 
    "venv": "dev"
}

venv dir structure is:

~/.venv> ls dev/lib/*/
dev/lib/python3.6/:
site-packages

dev/lib/python3.7/:
site-packages

VSCode shows a problems output:

Import 'sqlitedict' could not be resolved
't' is not bound
Import 'telegram.ext' could not be resolved

There are not resolved imports.

To fix it I did a symlink:

~/.venv> cd dev/lib/
~/.v/d/lib> ln -s python3.7/site-packages/ ./site-packages

After restarting of VSCode the problems output is:

't' is not bound

It solved my issue with not resolved imports.
As referenced above the problem may be in the pyright code:
https://github.com/Microsoft/pyright/blob/5cde770e9ddb4de12f2b8f675db7aa124fe378c3/server/src/analyzer/pythonPathUtils.ts#L52-L53

from pyright.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.