0
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?

[WSL]returned non-zero exit status 1でvenvが作成できない

0
Posted at

環境

Windows 11
WSL2, Ubuntu-24.04
apt update && apt upgrade済み
python 3.12(初期インストールされてたやつ)

何が起こったか

以下のエラーメッセージが出てvenv環境を作成することができませんでした。
WSLでマウントされたWindowsのCドライブ上にvenvを作成しようとしたところこのエラーが出ました。

Error: Command '['/mnt/c/Users/~~~/venv/bin/python3', '-m', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.

原因・解決法

CドライブがうまくWSLでマウントされていなかった。

以下の記事を参考に、下記のコマンドを実行すると解決しました。

cd ~
sudo umount /mnt/c
sudo mount -t drvfs C: /mnt/c -o metadata

venvはsource venv/bin/activateで有効化できます。

追加事項

WSLの初期状態ではPythonのみインストールされているようで、
pipvenvも動作しませんでした。
そのため、以下の部分も追加で実行しました。
(python3.12-venvとpython3-venvのどちらが正解だったのかはわかりません)

sudo apt install python3-pip
sudo apt install python3.12-venv
sudo apt install python3-venv
0
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
0
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?