Skip to content

Installing autopep8 with pipenv throws an error #7393

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

Closed
afonsosantos opened this issue Sep 13, 2019 · 3 comments
Closed

Installing autopep8 with pipenv throws an error #7393

afonsosantos opened this issue Sep 13, 2019 · 3 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster

Comments

@afonsosantos
Copy link

afonsosantos commented Sep 13, 2019

Environment data

  • VS Code version: 1.38.1
  • Extension version (available under the Extensions sidebar): 2019.9.34911
  • OS and version: Windows 10 Home (build 1903)
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.7 32 bits
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): pipenv

Expected behaviour

VS Code would install the autopep8 package using pipenv

Actual behaviour

An error is ocurring and the installation failing

Steps to reproduce:

  1. Load a Python file
  2. Try to format the file
  3. Watch the notification and select to install autopep8
  4. Watch the error in the console

Logs

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

Nothing in there relevant to this issue (only pylint not installed errors)

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help; turn on source maps to make any tracebacks be useful by running Enable source map support for extension debugging)

Nothing either

Output from the CMD Windows console when trying to install autopep8

(myschool-app) X:\Programação\Projetos\Python\myschool-app>pipenv install autopep8 --dev
Courtesy Notice: Pipenv found itself running within a virtual environment, so it will automatically use that environment, instead of creating its own for any project. You can set PIPENV_IGNORE_VIRTUALENVS=1 to force pipenv to ignore that environment and create its own instead. You can set PIPENV_VERBOSITY=-1 to suppress this warning.
Installing autopep8…
WARNING: location not created nor specified
Installation Failed
Adding autopep8 to Pipfile's [dev-packages]…
Traceback (most recent call last):
  File "c:\program files (x86)\python37-32\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\program files (x86)\python37-32\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Program Files (x86)\Python37-32\Scripts\pipenv.exe\__main__.py", line 9, in <module>
  File "c:\program files (x86)\python37-32\lib\site-packages\pipenv\vendor\click\core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "c:\program files (x86)\python37-32\lib\site-packages\pipenv\vendor\click\core.py", line 717, in main
    rv = self.invoke(ctx)
  File "c:\program files (x86)\python37-32\lib\site-packages\pipenv\vendor\click\core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\program files (x86)\python37-32\lib\site-packages\pipenv\vendor\click\core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\program files (x86)\python37-32\lib\site-packages\pipenv\vendor\click\core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "c:\program files (x86)\python37-32\lib\site-packages\pipenv\vendor\click\decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "c:\program files (x86)\python37-32\lib\site-packages\pipenv\vendor\click\core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "c:\program files (x86)\python37-32\lib\site-packages\pipenv\vendor\click\decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "c:\program files (x86)\python37-32\lib\site-packages\pipenv\cli\command.py", line 254, in install
    editable_packages=state.installstate.editables,
  File "c:\program files (x86)\python37-32\lib\site-packages\pipenv\core.py", line 1971, in do_install
    crayons.normal(fix_utf8("…"), bold=True),
  File "c:\program files (x86)\python37-32\lib\site-packages\pipenv\vendor\vistir\spin.py", line 218, in write
    return self.write_err(text)
  File "c:\program files (x86)\python37-32\lib\site-packages\pipenv\vendor\vistir\spin.py", line 238, in write_err
    self.out_buff.write(to_text(text))
ValueError: I/O operation on closed file

Not sure if this is a Python issue or a VS Code issue

EDIT: When trying to run pipenv install autopep8 --dev manually (inside the venv) that command does not work also

Another Edit: If inside the current venv i run pipenv shell, these commands work normally. VS Code is not launching the correct Virtual Enviroment.
In order to pipenv venv's to work, we need to run the pipenv shell and not using the activate script, like VS Code is doing.

Again, I think this may not be related to the Python Extension.

@afonsosantos afonsosantos added triage-needed Needs assignment to the proper sub-team bug Issue identified by VS Code Team member as probable bug labels Sep 13, 2019
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Sep 16, 2019
@ericsnowcurrently
Copy link

@afonsosantos, thanks for letting us know about this. It is unclear from your description, it is unclear if this is something the extension needs to fix. Are you saying the extension should use pipenv shell?

@ericsnowcurrently ericsnowcurrently added the info-needed Issue requires more information from poster label Sep 16, 2019
@afonsosantos
Copy link
Author

afonsosantos commented Sep 16, 2019

@ericsnowcurrently Thanks for the answer,

Yes, that's it. Even with the right Python Interpreter selected in VS Code, when launching a terminal or installing autopep8, it tries to activate with the activate script and not using the pipenv shell.
Also, if I activate the virtualenv using pipenv shell outside of VS Code, it works without any problems, and all consoles inside VS Code use the right virtual env.

@DonJayamanne
Copy link

Duplicate of #4245

@DonJayamanne DonJayamanne marked this as a duplicate of #4245 Sep 17, 2019
@ghost ghost removed the triage label Sep 17, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Sep 24, 2019
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 info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

4 participants