Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conda env defined $PYTHONPATH is ignored - breaks pylint, refactoring,... #13962

Closed
TotallyFred opened this issue Sep 17, 2020 · 3 comments
Closed
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug

Comments

@TotallyFred
Copy link

TotallyFred commented Sep 17, 2020

Issue Type: Bug

I set up Code Studio to use a conda environment called LMCrypto for my project.

Here is the content from settings.json that was generated by selecting the environment from the bottom left blue status line:

(LMCrypto)# cat ../.vscode/settings.json
{
"python.pythonPath": "/Users/fdetienn/anaconda3/envs/LMCrypto/bin/python"
}

This environment contains a PYTHONPATH:

(LMCrypto)# echo $PYTHONPATH
/Users/fdetienn/Documents/Programming/LazyMaestro/standalone/lmcrypto

When CodeStudio runs pylint (upon saving the file), all the import for my own modules are underlined in red with a pylint-import error .

When I run pylint from a terminal (including in code studio's terminal), pylint properly detects the import path from PYTHONPATH.

I.e. the problem only appears when Code Studio runs pylint on its own.

Seemingly, code refactoring is also broken.

This was working nicely before my vacation and seems to have appeared with the latest upgrade.

Extension version: 2020.8.109390
VS Code version: Code 1.49.0 (e790b931385d72cf5669fcefc51cdf65990efa5d, 2020-09-10T17:39:53.251Z)
OS version: Darwin x64 19.6.0

System Info
Item Value
CPUs Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz (8 x 2900)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
webgl: enabled
webgl2: enabled
Load (avg) 3, 3, 3
Memory (System) 16.00GB (0.10GB free)
Process Argv
Screen Reader no
VM 0%
@ghost ghost added the triage-needed Needs assignment to the proper sub-team label Sep 17, 2020
@TotallyFred TotallyFred changed the title cond env defined $PYTHONPATH is ignored - breaks pylint, refactoring,... Conda env defined $PYTHONPATH is ignored - breaks pylint, refactoring,... Sep 17, 2020
@karthiknadig
Copy link
Member

Try these steps when working with conda. We have some know issues with conda due to limitation in conda itself and VS Code:

  1. Turn off auto activation. To do this, disable these two settings, ideally only for the project you are working on:
    image
  2. Exit VS Code.
  3. Open Anaconda Prompt, navigate to your project.
  4. Activate the environment that you want.
  5. Run code . or code project.code-workspace to launch VS Code.

This will give you an activate environment, and the extension will not have to try and activate every time a terminal is created.

@karthiknadig karthiknadig self-assigned this Sep 17, 2020
@karthiknadig karthiknadig added triage bug Issue identified by VS Code Team member as probable bug labels Sep 17, 2020
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Sep 17, 2020
@TotallyFred
Copy link
Author

Thanks! I had completely overlooked these options all the way at the bottom.

In my case:

  • Activate on load was disabled.
  • Activate in terminal created by the extension was enabled.

I tried your proposal and it works.

I also tried the reverse: I activated both options and it works without having to fire up a terminal. Ie everything works as expected (pylint works again, the first terminal jumps into the conda environment, and all) which is more comfortable.

I have no idea how "activate on load" got disabled. I'm pretty sure I didn't change it (but only 99%). Or maybe they're new options?

Now I read you when you say there are some known issues with conda. Maybe I'm getting lucky but I'll keep my eyes open. Can you point me to the existing bugs to be aware of the symptoms ?

@karthiknadig
Copy link
Member

We have not changed those settings or added new ones. So i am not sure what went wring there.
You can see the issues with conda and terminal here: #5344 #4568

@ghost ghost removed the triage label Sep 17, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

No branches or pull requests

2 participants