1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

VSCodeでvenvがdeactivateできない

Last updated at Posted at 2025-01-14

症状

  1. VSCode の Terminal で venv を起動
  2. $ deactivate をしないまま VSCode を閉じる
  3. 再度 VSCode を開いた時に,venv が自動で起動されるが $ deactivate を受け付けない

原因

再起動した VSCode が Terminal から venv を起動するが,正常起動したわけではないため venv を起動する前の環境への戻り値がなく,$ deactivate を受け付けない.

なんか原因はVSCodeのPython拡張機能な気がする

具体的にはこれ

解決策

設定の terminal.integrated.shellIntegration.enabled を false にする.

もしくは,

VS Code の キャッシュや設定ファイルを削除する.
プロジェクトのファイルの PATH はデフォルト設定やワークスペース設定で異なるが,グローバルな設定ファイルの場所は以下.

  • Windows: %APPDATA%\Code\User
  • Mac: ~/Library/Application Support/Code/User
  • Linux: ~/.config/Code/User

これらのフォルダを削除してvenvに関連するキャッシュや設定をリセットします.
ただし,VS Codeの状態がリセットされるので,どこかにコピーをとってバックアップしておくといいかもしれません.

終わりに

VSCode を閉じるときは気をつけましょう….

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?