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

Can't autodetect pipenv on 2018.2.1 #1027

Closed
frostming opened this issue Mar 11, 2018 · 23 comments
Closed

Can't autodetect pipenv on 2018.2.1 #1027

frostming opened this issue Mar 11, 2018 · 23 comments
Labels
bug Issue identified by VS Code Team member as probable bug

Comments

@frostming
Copy link

frostming commented Mar 11, 2018

Environment data

  • VS Code version: 1.21.0: 2018 Feb
  • Extension version (available under the Extensions sidebar): 2018.2.1
  • OS and version: macOs High Sierra 10.13.3
  • Python version: CPython 3.6.4
  • Type of virtual environment used (if applicable): pipenv
  • Relevant/affected Python packages and their versions: pipenv==11.3.2

Actual behavior

When open a project with Pipfile, the interpreter is bare Python 3.6.4

Expected behavior

When open a project with Pipfile, the interpreter will be autodetected as Python3.6.4(pipenv) and uses the virtualenv created by pipenv

Steps to reproduce:

  1. pipenv install to create a virtualenv for requests_html
  2. Open the project in VSCode

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

Only linting messages

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help)

[Extension Host] (node:33660) DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
t.log @ workbench.main.js:sourcemap:257
@DonJayamanne
Copy link

I've tested this at my end and it seems to work.
Please could you provide the following info:

  • Do you have a .vscode folder created (it should get created automatically)
  • What are the contents of the .vscode/settings.json file?
  • When in the requests_html directory please type the following in the terminal window and let me know what you get:
    pipenv --venv

@DonJayamanne DonJayamanne added bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster feature-interpreter labels Mar 11, 2018
@frostming
Copy link
Author

I deleted .vscode folder and restarted. Since I haven't changed interpreter manually, the folder didn't create again.

The other question:

> pipenv --venv
/Users/fming/.local/share/virtualenvs/requests-html--yMYlALf

@DonJayamanne
Copy link

deleted .vscode folder and restarted.

What was in the folder?
How did it get created in the first place?

@DonJayamanne
Copy link

Once in vscode please remember to create/open a python file, this will activate the python extension.

@frostming
Copy link
Author

Yes, I opened a py file.

The first time I chose the python interpreter so it was written in settings.

@DonJayamanne DonJayamanne added needs verification and removed info-needed Issue requires more information from poster labels Mar 11, 2018
@brettcannon
Copy link
Member

Two things:

  1. Can you update your version of pipenv? (latest version is 11.6.0)
  2. Where is your Pipfile in your workspace? (E.g. is it at the root folder?)

@brettcannon brettcannon added info-needed Issue requires more information from poster and removed needs verification labels Mar 12, 2018
@brettcannon
Copy link
Member

And thanks for helping us with this! 😃

@brettcannon
Copy link
Member

And as a third thing, can you do this before you upgrade?

pipenv --venv
echo $?

Basically we would like to know if the pipenv --venv command had a non-zero exit code.

@frostming
Copy link
Author

@brettcannon Thanks for your reply

  1. The pipenv updates really quickly, I tried upgrading several times and the issue existed(The last trial was 11.5.3)
  2. Yes the Pipfile is in my workspace root.
  3. I am now working on Windows environment and all work fine. It seems only mac has this issue, I will reply to you later when I use my Mac.

@frostming
Copy link
Author

@brettcannon

It is still not working after I upgraded pipenv to 11.6.0 and the pipenv --venv gives a 0 exit code.

Thanks

@brettcannon brettcannon added needs verification and removed info-needed Issue requires more information from poster labels Mar 13, 2018
@brettcannon
Copy link
Member

brettcannon commented Mar 13, 2018

Hmm, weird since it works for people on the team who develop on Mac. We will see if we can replicate it somehow on our end.

@naphta
Copy link

naphta commented Mar 14, 2018

Working for me now with the latest pipenv installed (directly via homebrew for what it's worth)

@DonJayamanne
Copy link

@frostming

Thanks

@swordsp
Copy link

swordsp commented Mar 15, 2018

I met the same issue.

In my case I have two root folders in a workspace, say project1 and project2, both have been configured by pipenv. I have set "python.pythonPath" to different values accordingly in project1/.vscode/settings.json and project2/.vscode/settings.json. When open a python file inside project2 and try to select the python interpreter, VSCode can only detect the one configured for project1.

@DonJayamanne
Copy link

@swordsp
Please could you file a separate issue, they seem to be separate issues.

@frostming
Copy link
Author

@DonJayamanne Thanks for your effort

I followed your instructions and it still turns out not working

log.log is attached

@DonJayamanne
Copy link

FYI here's the error captured:

Traceback (most recent call last):
  File "/usr/local/Cellar/pipenv/11.8.0/libexec/bin/pipenv", line 11, in <module>
    load_entry_point('pipenv==11.8.0', 'console_scripts', 'pipenv')()
  File "/usr/local/Cellar/pipenv/11.8.0/libexec/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/Cellar/pipenv/11.8.0/libexec/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 676, in main
    _verify_python3_env()
  File "/usr/local/Cellar/pipenv/11.8.0/libexec/lib/python3.6/site-packages/pipenv/vendor/click/_unicodefun.py", line 118, in _verify_python3_env
    'for mitigation steps.' + extra)
RuntimeError: Click will abort further execution because Python 3 was configured to use ASCII as encoding for the environment.  Consult http://click.pocoo.org/python3/for mitigation steps.

This system lists a couple of UTF-8 supporting locales that
you can pick from.  The following suitable locales where
discovered: af_ZA.UTF-8, am_ET.UTF-8, be_BY.UTF-8, bg_BG.UTF-8, ca_ES.UTF-8, cs_CZ.UTF-8, da_DK.UTF-8, de_AT.UTF-8, de_CH.UTF-8, de_DE.UTF-8, el_GR.UTF-8, en_AU.UTF-8, en_CA.UTF-8, en_GB.UTF-8, en_IE.UTF-8, en_NZ.UTF-8, en_US.UTF-8, es_ES.UTF-8, et_EE.UTF-8, eu_ES.UTF-8, fi_FI.UTF-8, fr_BE.UTF-8, fr_CA.UTF-8, fr_CH.UTF-8, fr_FR.UTF-8, he_IL.UTF-8, hr_HR.UTF-8, hu_HU.UTF-8, hy_AM.UTF-8, is_IS.UTF-8, it_CH.UTF-8, it_IT.UTF-8, ja_JP.UTF-8, kk_KZ.UTF-8, ko_KR.UTF-8, lt_LT.UTF-8, nl_BE.UTF-8, nl_NL.UTF-8, no_NO.UTF-8, pl_PL.UTF-8, pt_BR.UTF-8, pt_PT.UTF-8, ro_RO.UTF-8, ru_RU.UTF-8, sk_SK.UTF-8, sl_SI.UTF-8, sr_YU.UTF-8, sv_SE.UTF-8, tr_TR.UTF-8, uk_UA.UTF-8, zh_CN.UTF-8, zh_HK.UTF-8, zh_TW.UTF-8

@DonJayamanne
Copy link

@frostming

  • Please could you type the following into your console and let me know what you get for each:
    • echo $LC_ALL
    • echo $LANG
  • Finally, please could you try initializing the above env variables as described here http://click.pocoo.org/5/python3/

@frostming
Copy link
Author

@DonJayamanne I also searched the solution of this decode error of click but it didn't work out.
Both LC_ALL and LANG have been set to zh_CN.UTF-8.

I wonder why it can't work inside extension but works well in my terminal

Thanks

@DonJayamanne
Copy link

Please confirm you have quit and restarted VS Code, we need to ensure it has access to the new environment variables.
One simple approach is to quit all instances of vs code, then launch it from the terminal where you have defined your environment variables using code

@DonJayamanne DonJayamanne added the info-needed Issue requires more information from poster label Mar 16, 2018
@frostming
Copy link
Author

Yeah, after I tried several times, uninstall and reinstall vscode from homebrew.

It is working now! Congrats!

Thanks for all you've done here.

@DonJayamanne DonJayamanne added closed-verified fixed and removed info-needed Issue requires more information from poster labels Mar 16, 2018
@DonJayamanne DonJayamanne modified the milestone: March 2018 Mar 16, 2018
@frostming
Copy link
Author

frostming commented Mar 18, 2018

Final solution for those who encountered this issue:

Add below line in your .bash_profile or .zshrc for example:

launchctl setenv LC_ALL $(launchctl getenv LANG)

And restart your Dock by:

killall Dock

The dock will be restarted, and VSCode started from Docker or Finder will read the env rightly.

Work on macOs High Sierra 10.13.3 and Python extension 2018.2.1

@devguydavid
Copy link

launchctl getenv LANG wasn't returning anything for me, but $LANG is set by the time I get to .bash_profile, so I added this to my .bash_profile:

launchctl setenv LC_ALL $LANG

@lock lock bot locked as resolved and limited conversation to collaborators Jul 11, 2018
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

6 participants