Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WSL: pipenv shell does not launch a subshell #3489

Closed
markfaine opened this issue Jan 29, 2019 · 7 comments
Closed

WSL: pipenv shell does not launch a subshell #3489

markfaine opened this issue Jan 29, 2019 · 7 comments
Labels
Type: Duplicate This issue is a duplicate of an already-existing issue.

Comments

@markfaine
Copy link

Issue description

WSL on Windows 10 with Ubuntu 18.04
On WSL the command 'pipenv shell' does not launch a subshell or activate the environment. Due to #3488, I had to uninstall all Windows versions of Python to have success at creating the environment.

Expected result

Launching subshell in virtual environment…
(env-setup) mfaine@MSSLW17050462:/mnt/c/Users/mfaine/Desktop/env-setup$

Actual result

Launching subshell in virtual environment…
mfaine@MSSLW17050462:/mnt/c/Users/mfaine/Desktop/env-setup$

Typing exit here will close the terminal. It is possible to to manually activate the environment without launching a subshell with:

source $(pipenv --venv)/bin/activate

Steps to replicate

Pipfile:

[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]

[packages]

[requires]
python_version = "2.7"

Expected result

mfaine@MSSLW17050462:/mnt/c/Users/mfaine/Desktop/env-setup$ pipenv install
Creating a virtualenv for this project…
Pipfile: /mnt/c/Users/mfaine/Desktop/env-setup/Pipfile
Using /usr/bin/python2.7 (2.7.15rc1) to create virtualenv…
⠏ Creating virtual environment...New python executable in /home/mfaine/.local/share/virtualenvs/env-setup-tPXXVp16/bin/python2.7
Also creating executable in /home/mfaine/.local/share/virtualenvs/env-setup-tPXXVp16/bin/python
Installing setuptools, pip, wheel...
done.
Running virtualenv with interpreter /usr/bin/python2.7
✔ Successfully created virtual environment!
Virtualenv location: /home/mfaine/.local/share/virtualenvs/env-setup-tPXXVp16
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Updated Pipfile.lock (dfae9f)!
Installing dependencies from Pipfile.lock (dfae9f)…
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 0/0 — 00:00:00
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
mfaine@MSSLW17050462:/mnt/c/Users/mfaine/Desktop/env-setup$ pipenv shell
Launching subshell in virtual environment…
(env-setup) mfaine@MSSLW17050462:/mnt/c/Users/mfaine/Desktop/env-setup$
-------------------------------------------------------------------------------
$ pipenv --support

Pipenv version: '2018.11.26'

Pipenv location: '/home/mfaine/.local/lib/python3.6/site-packages/pipenv'

Python location: '/usr/bin/python3'

Python installations found:

  • 3.6.7: /usr/bin/python3
  • 3.6.7: /usr/bin/python3.6m
  • 2.7.15rc1: /usr/bin/python

PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '3.6.7',
 'os_name': 'posix',
 'platform_machine': 'x86_64',
 'platform_python_implementation': 'CPython',
 'platform_release': '4.4.0-43-Microsoft',
 'platform_system': 'Linux',
 'platform_version': '#1-Microsoft Wed Dec 31 14:42:53 PST 2014',
 'python_full_version': '3.6.7',
 'python_version': '3.6',
 'sys_platform': 'linux'}

System environment variables:

  • LS_COLORS
  • HOSTTYPE
  • LESSCLOSE
  • LANG
  • USER
  • PWD
  • HOME
  • NAME
  • SHELL
  • TERM
  • SHLVL
  • LOGNAME
  • PATH
  • LESSOPEN
  • _
  • PIP_DISABLE_PIP_VERSION_CHECK
  • PYTHONDONTWRITEBYTECODE
  • PIP_SHIMS_BASE_MODULE
  • PIP_PYTHON_PATH
  • PYTHONFINDER_IGNORE_UNSUPPORTED

Pipenv–specific environment variables:

Debug–specific environment variables:

  • PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/ProgramData/scoop/shims:/mnt/c/Windows:/mnt/c/Windows/System32:/mnt/c/Windows/System32/wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0:/mnt/c/Oracle/product/12.2.0/client_1/bin:/mnt/c/Program Files (x86)/Common Files/Oracle/Java/javapath_target_1966171:/mnt/c/Program Files/Microsoft Network Monitor 3:/mnt/c/Program Files (x86)/HID Global/ActivClient:/mnt/c/Program Files/HID Global/ActivClient:/mnt/c/Program Files/Intel/WiFi/bin:/mnt/c/Program Files/Common Files/Intel/WirelessCommon:/mnt/c/ProgramData/Oracle/Java/javapath_target_152566531:/mnt/c/Program Files/nodejs:/mnt/c/Program Files (x86)/Sennheiser/SoftphoneSDK:/mnt/c/Program Files (x86)/GnuPG/bin:/mnt/c/Program Files/PuTTY:/mnt/c/Vagrant/bin:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files (x86)/Microsoft SDKs/Azure/CLI2/wbin:/mnt/c/Program Files (x86)/Windows Kits/10/Windows Performance Toolkit:/mnt/c/Program Files (x86)/Windows Kits/10/Microsoft Application Virtualization/Sequencer:/mnt/c/Users/mfaine/scoop/shims:/mnt/c/Users/mfaine/AppData/Local/Microsoft/WindowsApps:/mnt/c/Program Files/Intel/WiFi/bin:/mnt/c/Program Files/Common Files/Intel/WirelessCommon:/mnt/c/Users/mfaine/AppData/Roaming/npm:/mnt/c/Users/mfaine/AppData/Local/Programs/Microsoft VS Code Insiders/bin:/mnt/c/Program Files/Oracle/VirtualBox:/home/mfaine/.local/bin
  • SHELL: /bin/bash
  • LANG: en_US.UTF-8
  • PWD: /mnt/c/Users/mfaine/Desktop/env-setup

Contents of Pipfile ('/mnt/c/Users/mfaine/Desktop/env-setup/Pipfile'):

[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]

[packages]


[requires]
python_version = "2.7"

Contents of Pipfile.lock ('/mnt/c/Users/mfaine/Desktop/env-setup/Pipfile.lock'):

{
    "_meta": {
        "hash": {
            "sha256": "ae4bdd7d4157baab65ae9d0e8389a6011e6b640995372c45ec81fa5d1ddfae9f"
        },
        "pipfile-spec": 6,
        "requires": {
            "python_version": "2.7"
        },
        "sources": [
            {
                "name": "pypi",
                "url": "https://pypi.org/simple",
                "verify_ssl": true
            }
        ]
    },
    "default": {},
    "develop": {}
}


@markfaine markfaine changed the title WSL: pipenv shell does start a new shell WSL: pipenv shell does launch a subshell Jan 29, 2019
@markfaine markfaine changed the title WSL: pipenv shell does launch a subshell WSL: pipenv shell does not launch a subshell Jan 29, 2019
@PetterS
Copy link

PetterS commented Feb 7, 2019

pipenv shell has always worked as it should for me on WSL, with or without python installed in Windows, on three different computers.

@frostming
Copy link
Contributor

Duplicate of #3807

@frostming frostming marked this as a duplicate of #3807 Jul 15, 2019
@frostming frostming added the Type: Duplicate This issue is a duplicate of an already-existing issue. label Jul 15, 2019
@DeepSpace2
Copy link

DeepSpace2 commented Nov 5, 2020

Hi. I might have missed something, but I'm not sure this is a duplicate of #3807.
I'm having a very similar problem as OP and #3807 does not look like it is related.

I'm able to create a venv with pipenv on WSL (even with the interpreter and the venv itself being in Windows paths), but I can't activate the environment (just like OP).

Creating the environment succeeds:

USER@DESKTOP-I9N0CPU:/mnt/d/Python Projects/Test$ ../../Python38/python.exe -m pipenv sync
Creating a virtualenv for this project...
Pipfile: D:\Python Projects\Test\Pipfile
Using D:/Python38/python.exe (3.8.5) to create virtualenv...
[   =] Creating virtual environment...created virtual environment CPython3.8.5.final.0-32 in 453ms
  creator CPython3Windows(dest=C:\Users\USER\.virtualenvs\Test-exH7qFFG, clear=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=C:\Users\USER\AppData\Local\pypa\virtualenv)
    added seed packages: pip==20.2.2, setuptools==49.6.0, wheel==0.35.1
  activators BashActivator,BatchActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator

Successfully created virtual environment!
Virtualenv location: C:\Users\USER\.virtualenvs\Test-exH7qFFG
Installing dependencies from Pipfile.lock (e46d2f)...
Ignoring importlib-metadata: markers 'python_version < "3.8"' don't match your environment
  ================================ 86/86 - 00:02:01
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
All dependencies are now up-to-date!
USER@DESKTOP-I9N0CPU:/mnt/d/Python Projects/Test$ ../../Python38/python.exe -m pipenv --venv
C:\Users\USER\.virtualenvs\Test-exH7qFFG

However activating it with pipenv shell fails:

USER@DESKTOP-I9N0CPU:/mnt/d/Python Projects/Test$ ../../Python38/python.exe -m pipenv shell
Launching subshell in virtual environment...
'bash.exe' is not recognized as an internal or external command,
operable program or batch file.

pipenv --support also breaks with a weird error:

USER@DESKTOP-I9N0CPU:/mnt/d/Python Projects/Test$ ../../Python38/python.exe -m pipenv --support

$ pipenv --support

Pipenv version: '2020.11.4'

Pipenv location: 'D:\\Python38\\lib\\site-packages\\pipenv'

Python location: 'D:\\Python38\\python.exe'

Python installations found:

Traceback (most recent call last):
  File "D:\Python38\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "D:\Python38\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "D:\Python38\lib\site-packages\pipenv\__main__.py", line 5, in <module>
    cli()
  File "D:\Python38\Lib\site-packages\pipenv\vendor\click\core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "D:\Python38\Lib\site-packages\pipenv\vendor\click\core.py", line 782, in main
    rv = self.invoke(ctx)
  File "D:\Python38\Lib\site-packages\pipenv\vendor\click\core.py", line 1236, in invoke
    return Command.invoke(self, ctx)
  File "D:\Python38\Lib\site-packages\pipenv\vendor\click\core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "D:\Python38\Lib\site-packages\pipenv\vendor\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "D:\Python38\Lib\site-packages\pipenv\vendor\click\decorators.py", line 73, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "D:\Python38\Lib\site-packages\pipenv\vendor\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "D:\Python38\Lib\site-packages\pipenv\vendor\click\decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "D:\Python38\lib\site-packages\pipenv\cli\command.py", line 139, in cli
    get_pipenv_diagnostics()
  File "D:\Python38\lib\site-packages\pipenv\help.py", line 33, in get_pipenv_diagnostics
    python_paths = finder.find_all_python_versions()
  File "D:\Python38\lib\site-packages\pipenv\vendor\pythonfinder\pythonfinder.py", line 328, in find_all_python_versions
    path_list = sorted(versions, key=version_sort, reverse=True)
AttributeError: 'NoneType' object has no attribute 'version_sort'

@frostming
Copy link
Contributor

@DeepSpace2 you should not use the Windows Python installation under WSL, although it appears to work correctly.

@DeepSpace2
Copy link

@frostming I see. Thanks for the clarification!

@ghost
Copy link

ghost commented Nov 5, 2020

I hope you have solved your problem @DeepSpace2. If not, try updating your pipenv version from 2018.11.26. For instance, the latest (as of right now) is 2020.11.4.

I just tested with the WSL Python 3 and Python 2 distribution under openSUSE and it worked fine. However, the release candidate version of Python your WSL distro has is suspicious... so that could indeed be the problem.

pyenv could solve your Python versioning issues.

@DeepSpace2
Copy link

@bromps I 'solved' it by recreating the environment with the WSL's interpreter as was suggested, as I'm already using pipenv 2020.11.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Duplicate This issue is a duplicate of an already-existing issue.
Projects
None yet
Development

No branches or pull requests

4 participants