pipenv fails to install Jupyter in a Python3 environment when Python2 is present
See original GitHub issueDescribe the issue briefly here.
pipenv
fails to install jupyter
in a newly created Python 3 environment when Python 2 is also present
Environment
OS Type : macOS Sierra 10.12.6 Python version: both Python2 and Python3 (installed and updated via homebrew)
Python 2
$ which python
/usr/local/bin/python
$ python --version
Python 2.7.14
Python 3
$ which python3
/usr/local/bin/python3
$ python --version
Python 3.6.3
Pip2
$ which pip
/usr/local/bin/pip
$ pip --version
pip 9.0.1 from /usr/local/lib/python2.7/site-packages (python 2.7)
Pip3
$ which pip3
/usr/local/bin/pip3
$ pip3 --version
pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)
Pipenv
$ which pipenv
/usr/local/bin/pipenv
$ pipenv --version
pipenv, version 8.2.7
Expected result
It seems that if you want to install Jupyter
for a Python3 environment, it wants to be installed using pip3
explicitly (at least that is what they say in the installation instructions).
If I understand correctly, pipenv
will invoke pip
to do the package installation but if you have a legacy Python2 installation, pip
will point to pip2
. So what do you do in this case when you want to create a Python3 environment?
My expectation was that when I create a new environment with pipenv --three
, it should invoke <cod>pip3 each time I install a package via pipenv install package
. It doesn’t seem to be the case or am I doing something wrong?
Actual result
See failure message below.
Steps to replicate
$ mkdir NewProject && cd NewProject
$ pipenv --three
Creating a virtualenv for this project…
Using /usr/local/bin/python3 to create virtualenv…
⠋Running virtualenv with interpreter /usr/local/bin/python3
Using base prefix '/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6'
New python executable in /Volumes/Macintosh_HD/Users/normansecord/Envs/NewProject-ezpWJ_ts/bin/python3.6
Also creating executable in /Volumes/Macintosh_HD/Users/normansecord/Envs/NewProject-ezpWJ_ts/bin/python
Installing setuptools, pip, wheel...done.
Virtualenv location: /Volumes/Macintosh_HD/Users/normansecord/Envs/NewProject-ezpWJ_ts
Creating a Pipfile for this project…
$ pipenv install jupyter
Installing jupyter…
Collecting jupyter
Using cached jupyter-1.0.0-py2.py3-none-any.whl
Collecting ipykernel (from jupyter)
Using cached ipykernel-4.6.1-py3-none-any.whl
Collecting notebook (from jupyter)
Using cached notebook-5.2.0-py2.py3-none-any.whl
Collecting ipywidgets (from jupyter)
Using cached ipywidgets-7.0.3-py2.py3-none-any.whl
Collecting jupyter-console (from jupyter)
Using cached jupyter_console-5.2.0-py2.py3-none-any.whl
Collecting nbconvert (from jupyter)
Using cached nbconvert-5.3.1-py2.py3-none-any.whl
Collecting qtconsole (from jupyter)
Using cached qtconsole-4.3.1-py2.py3-none-any.whl
Collecting tornado>=4.0 (from ipykernel->jupyter)
Collecting traitlets>=4.1.0 (from ipykernel->jupyter)
Using cached traitlets-4.3.2-py2.py3-none-any.whl
Collecting jupyter-client (from ipykernel->jupyter)
Using cached jupyter_client-5.1.0-py2.py3-none-any.whl
Collecting ipython>=4.0.0 (from ipykernel->jupyter)
Using cached ipython-6.2.1-py3-none-any.whl
Collecting jinja2 (from notebook->jupyter)
Using cached Jinja2-2.9.6-py2.py3-none-any.whl
Collecting ipython-genutils (from notebook->jupyter)
Using cached ipython_genutils-0.2.0-py2.py3-none-any.whl
Collecting nbformat (from notebook->jupyter)
Using cached nbformat-4.4.0-py2.py3-none-any.whl
Collecting jupyter-core (from notebook->jupyter)
Using cached jupyter_core-4.3.0-py2.py3-none-any.whl
Collecting terminado>=0.3.3; sys_platform != "win32" (from notebook->jupyter)
Collecting widgetsnbextension~=3.0.0 (from ipywidgets->jupyter)
Using cached widgetsnbextension-3.0.6-py2.py3-none-any.whl
Collecting prompt-toolkit<2.0.0,>=1.0.0 (from jupyter-console->jupyter)
Using cached prompt_toolkit-1.0.15-py3-none-any.whl
Collecting pygments (from jupyter-console->jupyter)
Using cached Pygments-2.2.0-py2.py3-none-any.whl
Collecting entrypoints>=0.2.2 (from nbconvert->jupyter)
Using cached entrypoints-0.2.3-py2.py3-none-any.whl
Collecting bleach (from nbconvert->jupyter)
Using cached bleach-2.1.1-py2.py3-none-any.whl
Collecting testpath (from nbconvert->jupyter)
Using cached testpath-0.3.1-py2.py3-none-any.whl
Collecting pandocfilters>=1.4.1 (from nbconvert->jupyter)
Collecting mistune>=0.7.4 (from nbconvert->jupyter)
Using cached mistune-0.8-py2.py3-none-any.whl
Collecting decorator (from traitlets>=4.1.0->ipykernel->jupyter)
Using cached decorator-4.1.2-py2.py3-none-any.whl
Collecting six (from traitlets>=4.1.0->ipykernel->jupyter)
Using cached six-1.11.0-py2.py3-none-any.whl
Collecting python-dateutil>=2.1 (from jupyter-client->ipykernel->jupyter)
Using cached python_dateutil-2.6.1-py2.py3-none-any.whl
Collecting pyzmq>=13 (from jupyter-client->ipykernel->jupyter)
Using cached pyzmq-16.0.3-cp36-cp36m-macosx_10_6_intel.whl
Collecting simplegeneric>0.8 (from ipython>=4.0.0->ipykernel->jupyter)
Collecting pexpect; sys_platform != "win32" (from ipython>=4.0.0->ipykernel->jupyter)
Using cached pexpect-4.2.1-py2.py3-none-any.whl
Requirement already satisfied: setuptools>=18.5 in /Volumes/Macintosh_HD/Users/normansecord/Envs/NewProject-ezpWJ_ts/lib/python3.6/site-packages (from ipython>=4.0.0->ipykernel->jupyter)
Collecting pickleshare (from ipython>=4.0.0->ipykernel->jupyter)
Using cached pickleshare-0.7.4-py2.py3-none-any.whl
Collecting appnope; sys_platform == "darwin" (from ipython>=4.0.0->ipykernel->jupyter)
Using cached appnope-0.1.0-py2.py3-none-any.whl
Collecting jedi>=0.10 (from ipython>=4.0.0->ipykernel->jupyter)
Using cached jedi-0.11.0-py2.py3-none-any.whl
Collecting MarkupSafe>=0.23 (from jinja2->notebook->jupyter)
Collecting jsonschema!=2.5.0,>=2.4 (from nbformat->notebook->jupyter)
Using cached jsonschema-2.6.0-py2.py3-none-any.whl
Collecting ptyprocess (from terminado>=0.3.3; sys_platform != "win32"->notebook->jupyter)
Using cached ptyprocess-0.5.2-py2.py3-none-any.whl
Collecting wcwidth (from prompt-toolkit<2.0.0,>=1.0.0->jupyter-console->jupyter)
Using cached wcwidth-0.1.7-py2.py3-none-any.whl
Collecting html5lib!=1.0b1,!=1.0b2,!=1.0b3,!=1.0b4,!=1.0b5,!=1.0b6,!=1.0b7,!=1.0b8,>=0.99999999pre (from bleach->nbconvert->jupyter)
Using cached html5lib-1.0b10-py2.py3-none-any.whl
Collecting parso==0.1.0 (from jedi>=0.10->ipython>=4.0.0->ipykernel->jupyter)
Using cached parso-0.1.0-py2.py3-none-any.whl
Collecting webencodings (from html5lib!=1.0b1,!=1.0b2,!=1.0b3,!=1.0b4,!=1.0b5,!=1.0b6,!=1.0b7,!=1.0b8,>=0.99999999pre->bleach->nbconvert->jupyter)
Using cached webencodings-0.5.1-py2.py3-none-any.whl
Installing collected packages: tornado, decorator, ipython-genutils, six, traitlets, python-dateutil, pyzmq, jupyter-core, jupyter-client, simplegeneric, ptyprocess, pexpect, pickleshare, appnope, wcwidth, prompt-toolkit, parso, jedi, pygments, ipython, ipykernel, MarkupSafe, jinja2, jsonschema, nbformat, entrypoints, webencodings, html5lib, bleach, testpath, pandocfilters, mistune, nbconvert, terminado, notebook, widgetsnbextension, ipywidgets, jupyter-console, qtconsole, jupyter
Successfully installed MarkupSafe-1.0 appnope-0.1.0 bleach-2.1.1 decorator-4.1.2 entrypoints-0.2.3 html5lib-1.0b10 ipykernel-4.6.1 ipython-6.2.1 ipython-genutils-0.2.0 ipywidgets-7.0.3 jedi-0.11.0 jinja2-2.9.6 jsonschema-2.6.0 jupyter-1.0.0 jupyter-client-5.1.0 jupyter-console-5.2.0 jupyter-core-4.3.0 mistune-0.8 nbconvert-5.3.1 nbformat-4.4.0 notebook-5.2.0 pandocfilters-1.4.2 parso-0.1.0 pexpect-4.2.1 pickleshare-0.7.4 prompt-toolkit-1.0.15 ptyprocess-0.5.2 pygments-2.2.0 python-dateutil-2.6.1 pyzmq-16.0.3 qtconsole-4.3.1 simplegeneric-0.8.1 six-1.11.0 terminado-0.6 testpath-0.3.1 tornado-4.5.2 traitlets-4.3.2 wcwidth-0.1.7 webencodings-0.5.1 widgetsnbextension-3.0.6
Adding jupyter to Pipfile's [packages]…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Traceback (most recent call last):
File "/usr/local/bin/pipenv", line 11, in <module>
sys.exit(cli())
File "/usr/local/lib/python2.7/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/pipenv/vendor/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python2.7/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python2.7/site-packages/pipenv/vendor/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python2.7/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/pipenv/cli.py", line 1847, in install
do_lock(system=system, pre=pre)
File "/usr/local/lib/python2.7/site-packages/pipenv/cli.py", line 1082, in do_lock
pre=pre
File "/usr/local/lib/python2.7/site-packages/pipenv/utils.py", line 452, in resolve_deps
resolved_tree.update(resolver.resolve(max_rounds=PIPENV_MAX_ROUNDS))
File "/usr/local/lib/python2.7/site-packages/pipenv/patched/piptools/resolver.py", line 102, in resolve
has_changed, best_matches = self._resolve_one_round()
File "/usr/local/lib/python2.7/site-packages/pipenv/patched/piptools/resolver.py", line 200, in _resolve_one_round
for dep in self._iter_dependencies(best_match):
File "/usr/local/lib/python2.7/site-packages/pipenv/patched/piptools/resolver.py", line 278, in _iter_dependencies
for dependency in self.repository.get_dependencies(ireq):
File "/usr/local/lib/python2.7/site-packages/pipenv/patched/piptools/repositories/pypi.py", line 153, in get_dependencies
result = reqset._prepare_file(self.finder, ireq)
File "/usr/local/lib/python2.7/site-packages/pipenv/patched/pip/req/req_set.py", line 639, in _prepare_file
abstract_dist.prep_for_dist()
File "/usr/local/lib/python2.7/site-packages/pipenv/patched/pip/req/req_set.py", line 134, in prep_for_dist
self.req_to_install.run_egg_info()
File "/usr/local/lib/python2.7/site-packages/pipenv/patched/pip/req/req_install.py", line 438, in run_egg_info
command_desc='python setup.py egg_info')
File "/usr/local/lib/python2.7/site-packages/pipenv/patched/pip/utils/__init__.py", line 707, in call_subprocess
% (command_desc, proc.returncode, cwd))
pip.exceptions.InstallationError: Command "python setup.py egg_info" failed with error code 1 in /var/folders/g1/srsny26x1ddfd469qxj675zw0000gn/T/tmpWWilqmbuild/functools32/
If I run pip install --three jupyter
, it removes the existing Python3 environment, creates a new Python3 environment and then I get the same error message again.
If I remove the Pipfile
, delete the environment and redo using Python 2, everything runs smoothly and installs.
$ rm -f Pipfile
$ rm -rf /Volumes/Macintosh_HD/Users/normansecord/Envs/NewProject-ezpWJ_ts
$ pipenv --two
Creating a virtualenv for this project…
Using /usr/local/bin/python2 to create virtualenv…
⠋Running virtualenv with interpreter /usr/local/bin/python2
New python executable in /Volumes/Macintosh_HD/Users/normansecord/Envs/NewProject-ezpWJ_ts/bin/python2.7
Also creating executable in /Volumes/Macintosh_HD/Users/normansecord/Envs/NewProject-ezpWJ_ts/bin/python
Installing setuptools, pip, wheel...done.
Virtualenv location: /Volumes/Macintosh_HD/Users/normansecord/Envs/NewProject-ezpWJ_ts
Creating a Pipfile for this project…
$ pipenv install jupyter
Installing jupyter…
Collecting jupyter
Using cached jupyter-1.0.0-py2.py3-none-any.whl
Collecting nbconvert (from jupyter)
Using cached nbconvert-5.3.1-py2.py3-none-any.whl
Collecting jupyter-console (from jupyter)
Using cached jupyter_console-5.2.0-py2.py3-none-any.whl
Collecting qtconsole (from jupyter)
Using cached qtconsole-4.3.1-py2.py3-none-any.whl
Collecting ipykernel (from jupyter)
Using cached ipykernel-4.6.1-py2-none-any.whl
Collecting notebook (from jupyter)
Using cached notebook-5.2.0-py2.py3-none-any.whl
Collecting ipywidgets (from jupyter)
Using cached ipywidgets-7.0.3-py2.py3-none-any.whl
Collecting mistune>=0.7.4 (from nbconvert->jupyter)
Using cached mistune-0.8-py2.py3-none-any.whl
Collecting testpath (from nbconvert->jupyter)
Using cached testpath-0.3.1-py2.py3-none-any.whl
Collecting jinja2 (from nbconvert->jupyter)
Using cached Jinja2-2.9.6-py2.py3-none-any.whl
Collecting entrypoints>=0.2.2 (from nbconvert->jupyter)
Using cached entrypoints-0.2.3-py2.py3-none-any.whl
Collecting pandocfilters>=1.4.1 (from nbconvert->jupyter)
Collecting traitlets>=4.2 (from nbconvert->jupyter)
Using cached traitlets-4.3.2-py2.py3-none-any.whl
Collecting bleach (from nbconvert->jupyter)
Using cached bleach-2.1.1-py2.py3-none-any.whl
Collecting jupyter-core (from nbconvert->jupyter)
Using cached jupyter_core-4.3.0-py2.py3-none-any.whl
Collecting pygments (from nbconvert->jupyter)
Using cached Pygments-2.2.0-py2.py3-none-any.whl
Collecting nbformat>=4.4 (from nbconvert->jupyter)
Using cached nbformat-4.4.0-py2.py3-none-any.whl
Collecting prompt-toolkit<2.0.0,>=1.0.0 (from jupyter-console->jupyter)
Using cached prompt_toolkit-1.0.15-py2-none-any.whl
Collecting ipython (from jupyter-console->jupyter)
Using cached ipython-5.5.0-py2-none-any.whl
Collecting jupyter-client (from jupyter-console->jupyter)
Using cached jupyter_client-5.1.0-py2.py3-none-any.whl
Collecting ipython-genutils (from qtconsole->jupyter)
Using cached ipython_genutils-0.2.0-py2.py3-none-any.whl
Collecting tornado>=4.0 (from ipykernel->jupyter)
Collecting terminado>=0.3.3; sys_platform != "win32" (from notebook->jupyter)
Collecting widgetsnbextension~=3.0.0 (from ipywidgets->jupyter)
Using cached widgetsnbextension-3.0.6-py2.py3-none-any.whl
Collecting MarkupSafe>=0.23 (from jinja2->nbconvert->jupyter)
Collecting configparser>=3.5; python_version == "2.7" (from entrypoints>=0.2.2->nbconvert->jupyter)
Collecting six (from traitlets>=4.2->nbconvert->jupyter)
Using cached six-1.11.0-py2.py3-none-any.whl
Collecting enum34; python_version == "2.7" (from traitlets>=4.2->nbconvert->jupyter)
Using cached enum34-1.1.6-py2-none-any.whl
Collecting decorator (from traitlets>=4.2->nbconvert->jupyter)
Using cached decorator-4.1.2-py2.py3-none-any.whl
Collecting html5lib!=1.0b1,!=1.0b2,!=1.0b3,!=1.0b4,!=1.0b5,!=1.0b6,!=1.0b7,!=1.0b8,>=0.99999999pre (from bleach->nbconvert->jupyter)
Using cached html5lib-1.0b10-py2.py3-none-any.whl
Collecting jsonschema!=2.5.0,>=2.4 (from nbformat>=4.4->nbconvert->jupyter)
Using cached jsonschema-2.6.0-py2.py3-none-any.whl
Collecting wcwidth (from prompt-toolkit<2.0.0,>=1.0.0->jupyter-console->jupyter)
Using cached wcwidth-0.1.7-py2.py3-none-any.whl
Collecting pexpect; sys_platform != "win32" (from ipython->jupyter-console->jupyter)
Using cached pexpect-4.2.1-py2.py3-none-any.whl
Collecting backports.shutil-get-terminal-size; python_version == "2.7" (from ipython->jupyter-console->jupyter)
Using cached backports.shutil_get_terminal_size-1.0.0-py2.py3-none-any.whl
Requirement already satisfied: setuptools>=18.5 in /Volumes/Macintosh_HD/Users/normansecord/Envs/NewProject-ezpWJ_ts/lib/python2.7/site-packages (from ipython->jupyter-console->jupyter)
Collecting pickleshare (from ipython->jupyter-console->jupyter)
Using cached pickleshare-0.7.4-py2.py3-none-any.whl
Collecting simplegeneric>0.8 (from ipython->jupyter-console->jupyter)
Collecting appnope; sys_platform == "darwin" (from ipython->jupyter-console->jupyter)
Using cached appnope-0.1.0-py2.py3-none-any.whl
Collecting pathlib2; python_version == "2.7" or python_version == "3.3" (from ipython->jupyter-console->jupyter)
Using cached pathlib2-2.3.0-py2.py3-none-any.whl
Collecting pyzmq>=13 (from jupyter-client->jupyter-console->jupyter)
Using cached pyzmq-16.0.3-cp27-cp27m-macosx_10_6_intel.whl
Collecting python-dateutil>=2.1 (from jupyter-client->jupyter-console->jupyter)
Using cached python_dateutil-2.6.1-py2.py3-none-any.whl
Collecting singledispatch (from tornado>=4.0->ipykernel->jupyter)
Using cached singledispatch-3.4.0.3-py2.py3-none-any.whl
Collecting certifi (from tornado>=4.0->ipykernel->jupyter)
Using cached certifi-2017.7.27.1-py2.py3-none-any.whl
Collecting backports-abc>=0.4 (from tornado>=4.0->ipykernel->jupyter)
Using cached backports_abc-0.5-py2.py3-none-any.whl
Collecting ptyprocess (from terminado>=0.3.3; sys_platform != "win32"->notebook->jupyter)
Using cached ptyprocess-0.5.2-py2.py3-none-any.whl
Collecting webencodings (from html5lib!=1.0b1,!=1.0b2,!=1.0b3,!=1.0b4,!=1.0b5,!=1.0b6,!=1.0b7,!=1.0b8,>=0.99999999pre->bleach->nbconvert->jupyter)
Using cached webencodings-0.5.1-py2.py3-none-any.whl
Collecting functools32; python_version == "2.7" (from jsonschema!=2.5.0,>=2.4->nbformat>=4.4->nbconvert->jupyter)
Collecting scandir; python_version < "3.5" (from pathlib2; python_version == "2.7" or python_version == "3.3"->ipython->jupyter-console->jupyter)
Installing collected packages: mistune, testpath, MarkupSafe, jinja2, configparser, entrypoints, pandocfilters, six, enum34, decorator, ipython-genutils, traitlets, webencodings, html5lib, bleach, jupyter-core, pygments, functools32, jsonschema, nbformat, nbconvert, wcwidth, prompt-toolkit, ptyprocess, pexpect, backports.shutil-get-terminal-size, scandir, pathlib2, pickleshare, simplegeneric, appnope, ipython, pyzmq, python-dateutil, jupyter-client, singledispatch, certifi, backports-abc, tornado, ipykernel, jupyter-console, qtconsole, terminado, notebook, widgetsnbextension, ipywidgets, jupyter
Successfully installed MarkupSafe-1.0 appnope-0.1.0 backports-abc-0.5 backports.shutil-get-terminal-size-1.0.0 bleach-2.1.1 certifi-2017.7.27.1 configparser-3.5.0 decorator-4.1.2 entrypoints-0.2.3 enum34-1.1.6 functools32-3.2.3.post2 html5lib-1.0b10 ipykernel-4.6.1 ipython-5.5.0 ipython-genutils-0.2.0 ipywidgets-7.0.3 jinja2-2.9.6 jsonschema-2.6.0 jupyter-1.0.0 jupyter-client-5.1.0 jupyter-console-5.2.0 jupyter-core-4.3.0 mistune-0.8 nbconvert-5.3.1 nbformat-4.4.0 notebook-5.2.0 pandocfilters-1.4.2 pathlib2-2.3.0 pexpect-4.2.1 pickleshare-0.7.4 prompt-toolkit-1.0.15 ptyprocess-0.5.2 pygments-2.2.0 python-dateutil-2.6.1 pyzmq-16.0.3 qtconsole-4.3.1 scandir-1.6 simplegeneric-0.8.1 singledispatch-3.4.0.3 six-1.11.0 terminado-0.6 testpath-0.3.1 tornado-4.5.2 traitlets-4.3.2 wcwidth-0.1.7 webencodings-0.5.1 widgetsnbextension-3.0.6
Adding jupyter to Pipfile's [packages]…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Updated Pipfile.lock (fbd131)!
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (6 by maintainers)
Top GitHub Comments
@nsecord your assumptions are correct, and actually pipenv does this correctly. Note that in the first instance you saw:
The issue is with how
pip-tools
, the package we use for resolvingPipfile.lock
, handles its resolution. Specifically with python 2 based installs of pipenv, pip-tools has trouble managing dependency resolution when installing python 3 based virtualenvs. This is a known issue and can be resolved by uninstalling pipenv and reinstalling it withpip3 install pipenv3
orpip3 install pipenv --user
In my experience Python 3 doing stuff to python 2 stuff is a lot easier than python 2 doing stuff to python 3 stuff. A very well put together sentence I know, but ya’ll get the point!