LoginSignup
11
3

More than 1 year has passed since last update.

WindowsにPycharmの「Failed to create a virtual environment」解決

Posted at

事象

Windows11にPycharm CE版を入れて、「Python Interpreter」を設定する時に、「Failed to create a virtual environment」というエラーメッセージが出てしまって、設定できなかった。
メモとして、解決案を残します

解析

  • Pycharmに対して、何か環境にエラーが起きた時に、「idea.log」にエラーメッセージとか普通に残っています。
  • 「Help」→「Show log in Explorer」を押す
  • 「idea.log」中の内容を確認する

解決

エラー内容

INFO - #c.j.p.p.PyPackageManagerImpl - Fatal Python error: init_stdio_encoding: failed to get the Python codec name of the stdio encoding
Python runtime state: core initialized
LookupError: unknown encoding: windows-31j

Current thread 0x00000aa0 (most recent call first):
  <no Python frame>

原因

起動のdefault encodingは「windows-31j」にしてしまいました

解決方法

  • Pycharmのインストールフォルダーに「bin/pycharm64.exe.vmoptions」という起動オプション設定ファイルが存在しています
  • 最後に、encodingを「utf-8」に設定するようなオプションを追加する
-Dfile.encoding=UTF-8
  • Pycharmを再起動してからこの事象は直しました
11
3
3

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
11
3