Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'cygpath: not found' & 'exec: cmd: not found' for Pyenv on Windows WSL 2

I have been trying to get Tensorflow to recognize my GPU within WSL 2. However, I believe that is largely irrelevant for the problem I am having right now.

Whenever I try to run the pyenv command within WSL I get the following error:

/mnt/c/Users/USER/.pyenv/pyenv-win/bin/pyenv: 3: cygpath: not found
/mnt/c/Users/USER/.pyenv/pyenv-win/bin/pyenv: 3: exec: cmd: not found

Pyenv does work outside of the WSL environment.

Here are the details of my environment:

pyenv - 3.1.1
WSL Kernel - 5.15.133.1-1
WSL version - 2.0.9.0
Windows 10
Windows Version - 10.0.19045.3693

What can I do to make pyenv work inside WSL?

like image 429
Abe Brandsma Avatar asked Nov 07 '25 06:11

Abe Brandsma


1 Answers

It seemed that my WSL environment was referring to the pyenv version installed on windows and not the pyenv version installed within WSL (ubuntu).

Installing pyenv in WSL and setting the correct path should help. It can be done like this:

curl https://pyenv.run | bash

Then add the next bit of code to your ~/.bashrc and change the {USER} variable to your own username.

export PATH="/home/USER/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"

For more details on installing pyenv in WSL Ubuntu, see here.


p.s. If you get a 'permission denied' error with cygpath and exec:cmd, see here.

like image 101
Abe Brandsma Avatar answered Nov 08 '25 20:11

Abe Brandsma



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!