0

I'm using ubuntu 20.04 on WSL2 on Windows 10.

I've installed python, pip, and pipenv:

> which python
/mnt/c/Users/chris/.pyenv/pyenv-win/shims/python

> python3 -V
Python 3.8.10

> pip list
...
pip                    20.0.2
pipenv                 2022.1.8
platformdirs           2.4.1
...

> pipenv
/mnt/c/Users/chris/.pyenv/pyenv-win/shims/pipenv: bad interpreter: /bin/sh^M: no such file or directory

What is this /mnt/c/Users/chris/.pyenv/pyenv-win/shims/pipenv: bad interpreter: /bin/sh^M: no such file or directory error?

I thought it might have something to do with pipenv on my Windows 10 so I uninstalled that - but I get the same error.

Chris
  • 298
  • 2
  • 14
  • @9769953 What do you mean "you edited something on the Windows side, but then tried to execute it on the Linux side?" – Chris Jan 09 '22 at 01:53
  • The basic message is: be careful when you mix Windows and Linux. Preferably edit files you are going to use on Linux, on Linux (which means a non-gui editor, probably). If you copy from Windows to Linux, you may have to run something like `dos2unix` on that file. – 9769953 Jan 09 '22 at 01:54
  • I ran `sudo apt-get install dos2unix` but I still have the same error when I try to use `pipenv` @9769953 – Chris Jan 09 '22 at 01:55
  • Now I get this error: `/mnt/c/Users/chris/.pyenv/pyenv-win/shims/pipenv: 2: pyenv: not found` for `pipenv`. I believe I installed pip via `sudo apt install python3-pip` and I installed pipenv via `pip install pipenv` – Chris Jan 09 '22 at 01:57
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/240879/discussion-between-chris-and-9769953). – Chris Jan 09 '22 at 02:00
  • I updated my .zshrc path as per this thread: https://github.com/pyenv/pyenv-virtualenv/issues/233#issuecomment-490677591 and now `pyenv` returns `pyenv 2.2.3` but `pipenv` returns `pyenv: Scripts/pipenv: command not found` – Chris Jan 09 '22 at 02:09
  • The fact that your paths include `/mnt/c/Users/chris` instead of `/home/christ` worries me, in the sense that that seems to point to a Windows user's path, used on Linux. That would potentially make a mess of things. – 9769953 Jan 09 '22 at 02:09
  • typing `$HOME` then `pwd` gives me `/home/chris` – Chris Jan 09 '22 at 02:10
  • (`printenv HOME` would have done the trick, without requiring changing directories.) – 9769953 Jan 09 '22 at 02:13
  • I just installed python (again?) via pyenv `pyenv install -v 3.9.9`... `pyenv versions` gives `* system (set by /home/chris/.pyenv/version)` and `which python` gives `/mnt/c/Users/chris/.pyenv/pyenv-win/shims/python`... `pyenv which python` also gives `/mnt/c/Users/chris/.pyenv/pyenv-win/shims/python` – Chris Jan 09 '22 at 02:20
  • `which python` gives `/mnt/c/Users/chris/.pyenv/pyenv-win/shims/python` – Chris Jan 09 '22 at 02:23
  • Oh! I'm not entirely sure what went right but `pipenv` works now after I tried `sudo apt-get install python-is-python3` – Chris Jan 09 '22 at 02:26
  • `which python` now returns `usr/bin/python` – Chris Jan 09 '22 at 02:26
  • I think this is solved..? Maybe? I was very close to doing a fresh ubuntu install and trying to figure it out from scratch. Thanks very much for the help and your time :) – Chris Jan 09 '22 at 02:27
  • Depends on what you want: you are now kind-of stuck with the system Python, which is not as easily upgradeable as pyenv's Python. But if you're fine with that, ignore pyenv's Python and use the system-installed Python. – 9769953 Jan 09 '22 at 02:28
  • Also, to make absolutely sure you always have the corresponding `pip` with `python`, use e.g. `python -m pip install pipenv`. That will match pip with the right python. You can probably do the same with `pipenv`, like: `python -m pipenv ...`. – 9769953 Jan 09 '22 at 02:29
  • But the pyenv & Python in `/mnt/c/Users/chris/` definitely seem to be a bit too much Windows influenced/installed, given the original error you got. You'll want to avoid those. But it may also mean that, on the Windows side (if you are running Python e.g. in PowerShell), you'll be using a completely different installation. That is actually a good thing: keep those separate (it may just mean installing packages twice: once for WSL, and once for Windows), if you want to use both. – 9769953 Jan 09 '22 at 02:31

0 Answers0