Skip to content
This repository has been archived by the owner on Apr 14, 2022. It is now read-only.

Language Server does not work with PYTHONPATH=./ #849

Closed
DonJayamanne opened this issue Apr 1, 2019 · 12 comments · Fixed by #966
Closed

Language Server does not work with PYTHONPATH=./ #849

DonJayamanne opened this issue Apr 1, 2019 · 12 comments · Fixed by #966
Assignees
Milestone

Comments

@DonJayamanne
Copy link

@DonJayamanne commented on Sun Mar 31 2019

  • Open the behave repo
  • Use python 3.7
  • OS Mac
  • Enable the following in settings.json
	"python.analysis.downloadChannel": "daily",
	"python.analysis.logLevel": "Trace",
  • Add a .env file with the following contents:
PYTHONPATH=./

Delete the above .env file then it works

None of the Language Server functionality works

Screen Shot 2019-03-31 at 7 32 02 PM

@DonJayamanne DonJayamanne changed the title Language Server does not work in behave repo Language Server does not work with PYTHONPATH=./ Apr 1, 2019
@AlexanderSher AlexanderSher self-assigned this Apr 3, 2019
@vivlim
Copy link

vivlim commented Apr 16, 2019

I encountered this with a project that had two adjacent delimiters in PYTHONPATH, i.e. PYTHONPATH=::.
There was no clear way to tell what was happening, all I could observe was that I had a cpu core pinned by the language server & no completions were working. That core continues to be 100% utilized until the vscode window closes. I've observed it running for at least 20 minutes of cpu time, though it's probably run for longer.

(I ended up having adjacent delimiters because I was trying have a single PYTHONPATH that would work across windows & linux which both use different os.pathsep.)

@jakebailey
Copy link
Member

@vivlim Did you also encounter this on Mac/Linux?

@vivlimmsft
Copy link

@jakebailey yes, I saw this on an Ubuntu 18.04 machine

@jakebailey
Copy link
Member

jakebailey commented Apr 16, 2019

This should be fixed in 0.2.56+, if you'd like to retest.

@vivlimmsft
Copy link

Sure, I'll try it tonight. Thanks!!

@vivlim
Copy link

vivlim commented Apr 17, 2019

@jakebailey On 0.2.58.0, the language server no longer pins a cpu core at 100% when PYTHONPATH=::, which is better, but it still seems to be stuck initializing. I do not get any completions or any analysis status in the status bar.

Starting Microsoft Python language server.

Linter 'pep8' is not installed. Please install it or select another linter".
Error: Module 'pep8' not installed.

Linter 'pylint' is not installed. Please install it or select another linter".
Error: Module 'pylint' not installed.
[Info  - 6:20:32 p.m.] GetCurrentSearchPaths /home/vivlim/.local/share/virtualenvs/py-test-wKGYf3-f/bin/python 
[Info  - 6:20:32 p.m.] Python search paths:
[Info  - 6:20:32 p.m.]     /home/vivlim/.local/share/virtualenvs/py-test-wKGYf3-f/lib/python3.6
[Info  - 6:20:32 p.m.]     /home/vivlim/.local/share/virtualenvs/py-test-wKGYf3-f/lib/python3.6/lib-dynload
[Info  - 6:20:32 p.m.]     /usr/lib/python3.6
[Info  - 6:20:32 p.m.]     /home/vivlim/.local/share/virtualenvs/py-test-wKGYf3-f/lib/python3.6/site-packages
[Info  - 6:20:32 p.m.] Configuration search paths:
[Info  - 6:20:32 p.m.]     /home/vivlim
[Info  - 6:20:32 p.m.]     /home/vivlim/.local/share/virtualenvs/py-test-wKGYf3-f/lib/python36.zip
[Info  - 6:20:32 p.m.]     /home/vivlim/.local/share/virtualenvs/py-test-wKGYf3-f/lib/python3.6
[Info  - 6:20:32 p.m.]     /home/vivlim/.local/share/virtualenvs/py-test-wKGYf3-f/lib/python3.6/lib-dynload
[Info  - 6:20:32 p.m.]     /usr/lib/python3.6
[Info  - 6:20:32 p.m.]     /home/vivlim/.local/share/virtualenvs/py-test-wKGYf3-f/lib/python3.6/site-packages
[Info  - 6:20:32 p.m.]     /home/vivlim/.local/share/virtualenvs/py-test-wKGYf3-f/bin
<no output below this line, including the LS version number.>

If I comment out the line in .env that sets PYTHONPATH, it can initialize normally and I get completions.

@jakebailey
Copy link
Member

Can you show what the output for "configuration search paths" is with and without that variable set? Your home directory probably shouldn't be showing up there.

@vivlim
Copy link

vivlim commented Apr 17, 2019

Hm, I rebooted my machine and it no longer repros. I'm not sure what changed, the installed LS version is still 0.2.58.0 and I was getting a consistent repro before whenever I set PYTHONPATH=:: in addition to it working consistently when I didn't.

Regarding the configuration search paths, I think they contain my home dir because I'm using pipenv to manage virtual environments. Pipenv places them in ~/.local/share/virtualenvs.

[Info  - 9:51:42 p.m.] GetCurrentSearchPaths /home/vivlim/.local/share/virtualenvs/py-test-wKGYf3-f/bin/python 
[Info  - 9:51:42 p.m.] Python search paths:
[Info  - 9:51:42 p.m.]     /home/vivlim/.local/share/virtualenvs/py-test-wKGYf3-f/lib/python3.6
[Info  - 9:51:42 p.m.]     /home/vivlim/.local/share/virtualenvs/py-test-wKGYf3-f/lib/python3.6/lib-dynload
[Info  - 9:51:42 p.m.]     /usr/lib/python3.6
[Info  - 9:51:42 p.m.]     /home/vivlim/.local/share/virtualenvs/py-test-wKGYf3-f/lib/python3.6/site-packages
[Info  - 9:51:42 p.m.] Configuration search paths:
[Info  - 9:51:42 p.m.]     /home/vivlim/.local/share/virtualenvs/py-test-wKGYf3-f/lib/python36.zip
[Info  - 9:51:42 p.m.]     /home/vivlim/.local/share/virtualenvs/py-test-wKGYf3-f/lib/python3.6
[Info  - 9:51:42 p.m.]     /home/vivlim/.local/share/virtualenvs/py-test-wKGYf3-f/lib/python3.6/lib-dynload
[Info  - 9:51:42 p.m.]     /usr/lib/python3.6
[Info  - 9:51:42 p.m.]     /home/vivlim/.local/share/virtualenvs/py-test-wKGYf3-f/lib/python3.6/site-packages
[Info  - 9:51:42 p.m.]     /home/vivlim/.local/share/virtualenvs/py-test-wKGYf3-f/bin
[Info  - 9:51:43 p.m.] Microsoft Python Language Server version 0.2.58.0
[Info  - 9:51:43 p.m.] Initializing for /home/vivlim/.local/share/virtualenvs/py-test-wKGYf3-f/bin/python

@jakebailey
Copy link
Member

To be clear, the path I'm saying probably shouldn't be there is /home/vivlim, stuff that's in directories in the home are alright, but the actual $HOME shouldn't be a place where we're searching for Python code (unless that were explicitly stated, as weird as it would be).

@chdsbd
Copy link

chdsbd commented Apr 18, 2019

I just ran into this issue. Before an update that happened today, PYTHONPATH worked. Now with Microsoft Python Language Server version 0.2.59.0 it seems to be ignored.

I don't know what my version language server version was before the update today.

@jakebailey
Copy link
Member

Can you be more specific? What was working before that wasn't? If you set "python.analysis.logLevel": "Trace" and reload, do you see the paths you specified appear as "configuration search paths"?

@chdsbd
Copy link

chdsbd commented Apr 18, 2019

The paths that I want do appear as "configuration search paths", so I'm not sure what's going on. I'll try to make a repo that exhibits this behavior.

EDIT: I think I ran into #989 actually

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants