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

Error on importing time #726

Closed
DonJayamanne opened this issue Mar 9, 2019 · 29 comments
Closed

Error on importing time #726

DonJayamanne opened this issue Mar 9, 2019 · 29 comments
Assignees
Labels
Milestone

Comments

@DonJayamanne
Copy link

import time

This fails in the latest version of Language server

Screen Shot 2019-03-09 at 12 27 26 PM

Starting Microsoft Python language server.
[Info  - 10:59:43 AM] GetCurrentSearchPaths /Users/donjayamanne/.local/share/virtualenvs/pythonVSCode-5rU-mS3t/bin/python 
[Info  - 10:59:43 AM] SearchPaths:
[Info  - 10:59:43 AM]     /private/var/folders/22/0kj01mp12l3dsd1vw9vhfs6c0000gn/T/gpd33mwx.z0b
[Info  - 10:59:43 AM]     /Users/donjayamanne/.local/share/virtualenvs/pythonVSCode-5rU-mS3t/lib/python3.7
[Info  - 10:59:43 AM]     /Users/donjayamanne/.local/share/virtualenvs/pythonVSCode-5rU-mS3t/lib/python3.7/lib-dynload
[Info  - 10:59:43 AM]     /Users/donjayamanne/.pyenv/versions/3.7.0/lib/python3.7
[Info  - 10:59:43 AM]     /Users/donjayamanne/.local/share/virtualenvs/pythonVSCode-5rU-mS3t/lib/python3.7/site-packages
[Info  - 10:59:43 AM]     /Users/donjayamanne/.local/share/virtualenvs/pythonVSCode-5rU-mS3t/lib/python37.zip;/Users/donjayamanne/.local/share/virtualenvs/pythonVSCode-5rU-mS3t/lib/python3.7;/Users/donjayamanne/.local/share/virtualenvs/pythonVSCode-5rU-mS3t/lib/python3.7/lib-dynload;/Users/donjayamanne/.pyenv/versions/3.7.0/lib/python3.7;/Users/donjayamanne/.local/share/virtualenvs/pythonVSCode-5rU-mS3t/lib/python3.7/site-packages;
[Info  - 10:59:43 AM]     /Users/donjayamanne/.local/share/virtualenvs/pythonVSCode-5rU-mS3t/bin
[Info  - 10:59:47 AM] Microsoft Python Language Server version 0.2.16.0
[Info  - 10:59:47 AM] Initializing for /Users/donjayamanne/.local/share/virtualenvs/pythonVSCode-5rU-mS3t/bin/python
[Info  - 12:20:37 PM] Reloading modules... 
[Info  - 12:20:40 PM] done.
[Info  - 12:20:40 PM] Analysis restarted.
@AlexanderSher
Copy link
Contributor

On my machine, it works fine:

image

Do you have any exceptions?

@MikhailArkhipov
Copy link

I think the /Users/donjayamanne/.local/share/virtualenvs/pythonVSCode-5rU-mS3t/lib/python37.zip;/Users/donjayamanne/.local/share/virtualenvs/pythonVSCode-5rU-mS3t/lib/python3.7;/Users/donjayamanne/.local/share/virtualenvs/pythonVSCode-5rU-mS3t/lib/python3.7/lib-dynload;/Users/donjayamanne/.pyenv/versions/3.7.0/lib/python3.7;/Users/donjayamanne/.local/share/virtualenvs/pythonVSCode-5rU-mS3t/lib/python3.7/site-packages;
i.e. unseparated paths are the problem. Old code separated paths itself. Basically part of #720

@DonJayamanne
Copy link
Author

DonJayamanne commented Mar 11, 2019

Absolutely no exceptions, reloaded VSC and started working again... Note while this failed everything else worked with the language server..

@MikhailArkhipov
Copy link

Most probably #700 then

@DonJayamanne
Copy link
Author

I think I know whats wrong.
Came across this a number of times yesterday and today.
Today, import sys had the exact same problem.
Unfortunately the problem went away before I could grab any screenshots.

I think the problem is, the problems are listed before the module resolution completes.
Came across problems with import time, import sys
I think this can be quite confusing and annoying to users when there are underlines under such imports that are used and are standard.

@DonJayamanne
Copy link
Author

Identified in version Microsoft Python Language Server version 0.2.23.0

@MikhailArkhipov
Copy link

MikhailArkhipov commented Mar 15, 2019

@DonJayamanne - is is just a squiggle or completion is missing too? I think the problem is, the problems are listed before the module resolution completes. - I guess completion does work but we haven't updated the diagnostics?

@MikhailArkhipov MikhailArkhipov added this to the March 2019.1 milestone Mar 15, 2019
@DonJayamanne
Copy link
Author

Happened again for os, dataclass, etc...
Didn't check intellisense, will check next time it happens.
Screen Shot 2019-03-15 at 1 19 23 PM

@DonJayamanne
Copy link
Author

Just replicated for import sys

  • No intellisense
  • See below

gotodef

Here are the logs:

##########Linting Output - flake8##########
Starting Microsoft Python language server.
[Info  - 1:15:48 PM] GetCurrentSearchPaths /Users/donjayamanne/.virtualenvs/pythonVSCode-5rU-mS3t/bin/python 
[Info  - 1:15:48 PM] Python search paths:
[Info  - 1:15:48 PM]     /private/var/folders/22/0kj01mp12l3dsd1vw9vhfs6c0000gn/T/thmraoix.apg
[Info  - 1:15:48 PM]     /Users/donjayamanne/.virtualenvs/pythonVSCode-5rU-mS3t/lib/python3.7
[Info  - 1:15:48 PM]     /Users/donjayamanne/.virtualenvs/pythonVSCode-5rU-mS3t/lib/python3.7/lib-dynload
[Info  - 1:15:48 PM]     /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7
[Info  - 1:15:48 PM]     /Users/donjayamanne/.virtualenvs/pythonVSCode-5rU-mS3t/lib/python3.7/site-packages
[Info  - 1:15:48 PM] Configuration search paths:
[Info  - 1:15:48 PM]     /Users/donjayamanne/.virtualenvs/pythonVSCode-5rU-mS3t/lib/python37.zip;/Users/donjayamanne/.virtualenvs/pythonVSCode-5rU-mS3t/lib/python3.7;/Users/donjayamanne/.virtualenvs/pythonVSCode-5rU-mS3t/lib/python3.7/lib-dynload;/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7;/Users/donjayamanne/.virtualenvs/pythonVSCode-5rU-mS3t/lib/python3.7/site-packages;
[Info  - 1:15:48 PM]     /Users/donjayamanne/.virtualenvs/pythonVSCode-5rU-mS3t/bin
[Info  - 1:15:53 PM] Microsoft Python Language Server version 0.2.23.0
[Info  - 1:15:53 PM] Initializing for /Users/donjayamanne/.virtualenvs/pythonVSCode-5rU-mS3t/bin/python
[Info  - 1:18:48 PM] Reloading modules... 
[Info  - 1:18:50 PM] done.
[Info  - 1:18:50 PM] Analysis restarted.
##########Linting Output - flake8##########
##########Linting Output - flake8##########
##########Linting Output - flake8##########
##########Linting Output - flake8##########
11,4,E,E999:SyntaxError: invalid syntax
12,1,E,E402:module level import not at top of file
13,1,E,E402:module level import not at top of file
##########Linting Output - flake8##########
11,4,E,E999:SyntaxError: invalid syntax
12,1,E,E402:module level import not at top of file
13,1,E,E402:module level import not at top of file
##########Linting Output - flake8##########
##########Linting Output - flake8##########
9,4,E,E999:SyntaxError: invalid syntax
10,1,E,E402:module level import not at top of file
11,1,E,E402:module level import not at top of file
13,1,E,E402:module level import not at top of file
14,1,E,E402:module level import not at top of file
##########Linting Output - flake8##########
9,7,W,W291:trailing whitespace
9,7,E,E999:SyntaxError: invalid syntax
10,1,E,E402:module level import not at top of file
11,1,E,E402:module level import not at top of file
13,1,E,E402:module level import not at top of file
14,1,E,E402:module level import not at top of file
##########Linting Output - flake8##########
9,1,F,F811:redefinition of unused 'sys' from line 8
##########Linting Output - flake8##########
##########Linting Output - flake8##########
9,3,E,E999:SyntaxError: invalid syntax
10,1,E,E402:module level import not at top of file
11,1,E,E402:module level import not at top of file
13,1,E,E402:module level import not at top of file
14,1,E,E402:module level import not at top of file
##########Linting Output - flake8##########
10,1,E,E402:module level import not at top of file
11,1,E,E402:module level import not at top of file
13,1,E,E402:module level import not at top of file
14,1,E,E402:module level import not at top of file
##########Linting Output - flake8##########

@MikhailArkhipov
Copy link

Set you "python.analysis.logLevel": "Trace", pretty please

@DonJayamanne
Copy link
Author

Left it on, next time I see it i'll post more information. Try to retrace my steps.

@DonJayamanne
Copy link
Author

DonJayamanne commented Mar 19, 2019

Managed to replicate, though not sure when it stopped working, either way, here are the logs an other info:

  • Python Env - 3.7 (using PipEnv)
  • OS - Mac
  • import sys & import time not found
  • Screenshots

Screen Shot 2019-03-18 at 9 53 23 PM

Screen Shot 2019-03-18 at 9 53 27 PM

  • Logs
    Could not paste contents here as the log file is too large :(
    log.txt

@gramster gramster changed the title Unable to find time Error on importing time Mar 19, 2019
@DonJayamanne
Copy link
Author

I haven't been experiencing this issue lately.
Hence closing it, possible some changes in the latest versions have resolved this issue.

@DonJayamanne
Copy link
Author

DonJayamanne commented Mar 28, 2019

Its back, saw this a number of times today.
Screen Shot 2019-03-27 at 10 24 41 PM

Here are the logs:
logs.log

@DonJayamanne DonJayamanne reopened this Mar 28, 2019
@MikhailArkhipov
Copy link

May be related. The following test is unpredictable. Sometimes sys is unresolved, sometimes it is compiled builtin but analysis is empty.

        public async Task File() {
            const string code = @"
import sys
sys.
";
            var uri = await TestData.CreateTestSpecificFileAsync("a.py", code);
            await CreateServicesAsync(PythonVersions.LatestAvailable3X, uri.AbsolutePath);
            var rdt = Services.GetService<IRunningDocumentTable>();
            var doc = rdt.OpenDocument(uri, null, uri.AbsolutePath);

            var analysis = await doc.GetAnalysisAsync(Timeout.Infinite);
            var cs = new CompletionSource(new PlainTextDocumentationSource(), ServerSettings.completion);

            var completions = cs.GetCompletions(analysis, new SourceLocation(3, 5));
            completions.Should().HaveLabels("argv", "path", "exit");
        }

@MikhailArkhipov
Copy link

See also #779

@DonJayamanne
Copy link
Author

Same problem with import sys.
Screen Shot 2019-03-31 at 10 35 52 AM

@MikhailArkhipov
Copy link

[Info  - 9:05:10 PM] Reloading modules...
[Info  - 9:05:12 PM] done.
[Info  - 9:05:12 PM] Analysis restarted.

is suspicious. Looks like something is detected and changed and modules getting reloaded triggering the issue.

@MikhailArkhipov
Copy link

Yes, looks like restart of analysis is the issue.

image

@MikhailArkhipov
Copy link

@AlexanderSher - I think #871 addressed this?

@AlexanderSher
Copy link
Contributor

Yes

@MikhailArkhipov
Copy link

#871

@siriuspal
Copy link

siriuspal commented Aug 13, 2019

This needs to be reopened. I see this problem today - #1430

Version: 1.37.0 (user setup)
Commit: 036a6b1d3ac84e5ca96a17a44e63a87971f8fcc8
Date: 2019-08-08T02:33:50.993Z
Electron: 4.2.7
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Windows_NT x64 10.0.18362

@timharris777
Copy link

I agree this needs to be re-opened. I have the problem as well. i am on the latest version of vscode on a mac.

@timharris777
Copy link

@MikhailArkhipov

@sadikneipp
Copy link

Same problem here. Apparently happening only in python native libs (sys, traceback, pdb, logging).

Version: 1.37.1
Commit: f06011ac164ae4dc8e753a3fe7f9549844d15e35
Date: 2019-08-15T16:16:34.800Z
Electron: 4.2.7
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Darwin x64 18.5.0

@wookiesh
Copy link

Same problem

@jakebailey
Copy link
Member

If it happens after "analysis restarted", see #1156.

@gatopeich
Copy link

gatopeich commented Aug 29, 2019

Still failing for me on "import sys"...
Reloading the window fixes it sometimes. Maybe #1156?

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

Successfully merging a pull request may close this issue.

9 participants