Pipenv isntall時にエラーが出る


Sponsored Link

2018/10/10追記

pipenvのバージョンを2018.10.9にしたところ解消し、pip18.1が問題なく利用できました。

pipenv installがうまくいかない

新規でリポジトリを作った際にPipenv installしたらエラーが出るようになった。 ので対処方法を調べたのだけど、結論から書くとpipのバージョンを18.0にすればOKでした。 2018/10/7時点の内容です。

$ pipenv install bs4
Installing bs4...
Traceback (most recent call last):
  File "/home/user/.anyenv/envs/pyenv/versions/3.7.0/bin/pipenv", line 11, in <module>
    sys.exit(cli())
  File "/home/user/.anyenv/envs/pyenv/versions/3.7.0/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/user/.anyenv/envs/pyenv/versions/3.7.0/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/user/.anyenv/envs/pyenv/versions/3.7.0/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/user/.anyenv/envs/pyenv/versions/3.7.0/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/user/.anyenv/envs/pyenv/versions/3.7.0/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/user/.anyenv/envs/pyenv/versions/3.7.0/lib/python3.7/site-packages/pipenv/cli.py", line 435, in install
    selective_upgrade=selective_upgrade,
  File "/home/user/.anyenv/envs/pyenv/versions/3.7.0/lib/python3.7/site-packages/pipenv/core.py", line 1971, in do_install
    pypi_mirror=pypi_mirror,
  File "/home/user/.anyenv/envs/pyenv/versions/3.7.0/lib/python3.7/site-packages/pipenv/core.py", line 1375, in pip_install
    package_name.split('--hash')[0].split('--trusted-host')[0]
  File "/home/user/.anyenv/envs/pyenv/versions/3.7.0/lib/python3.7/site-packages/pipenv/vendor/requirementslib/models/requirements.py", line 704, in from_line
    line, extras = _strip_extras(line)
TypeError: 'module' object is not callable

ということで調べてみたところIssueが上がってた(pip 18.1 causes “TypeError: ‘module’ object is not callable”)。 pipのバージョンが18.1だとダメな様子。

$ pipenv run pip --version
pip 18.1 from /home/user/.local/share/virtualenvs/piptest-G3GN52P4/lib/python3.7/site-packages/pip (python 3.7)

はい。18.0に下げましょう。


Sponsored Link


venvのpipのバージョンを下げる

$ pipenv run pip install -U pip==18.0
Collecting pip==18.0
  Using cached https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf940/pip-18.0-py2.py3-none-any.whl
Installing collected packages: pip
  Found existing installation: pip 18.1
    Uninstalling pip-18.1:
      Successfully uninstalled pip-18.1
Successfully installed pip-18.0

$ pipenv run pip --version
pip 18.0 from /home/user/.local/share/virtualenvs/piptest-G3GN52P4/lib/python3.7/site-packages/pip (python 3.7)

再度pipenv installしてみると

$ pipenv install  bs4
Installing bs4...
Traceback (most recent call last):
  File "/home/user/.anyenv/envs/pyenv/versions/3.7.0/bin/pipenv", line 11, in <module>
    sys.exit(cli())
  File "/home/user/.anyenv/envs/pyenv/versions/3.7.0/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/user/.anyenv/envs/pyenv/versions/3.7.0/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/user/.anyenv/envs/pyenv/versions/3.7.0/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/user/.anyenv/envs/pyenv/versions/3.7.0/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/user/.anyenv/envs/pyenv/versions/3.7.0/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/user/.anyenv/envs/pyenv/versions/3.7.0/lib/python3.7/site-packages/pipenv/cli.py", line 435, in install
    selective_upgrade=selective_upgrade,
  File "/home/user/.anyenv/envs/pyenv/versions/3.7.0/lib/python3.7/site-packages/pipenv/core.py", line 1971, in do_install
    pypi_mirror=pypi_mirror,
  File "/home/user/.anyenv/envs/pyenv/versions/3.7.0/lib/python3.7/site-packages/pipenv/core.py", line 1375, in pip_install
    package_name.split('--hash')[0].split('--trusted-host')[0]
  File "/home/user/.anyenv/envs/pyenv/versions/3.7.0/lib/python3.7/site-packages/pipenv/vendor/requirementslib/models/requirements.py", line 704, in from_line
    line, extras = _strip_extras(line)
TypeError: 'module' object is not callable

だめです。

pyenv側のpipも18.0にしてリトライ

pip install -U pip==18.0
Collecting pip==18.0
  Using cached https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf940/pip-18.0-py2.py3-none-any.whl
Installing collected packages: pip
  Found existing installation: pip 18.1
    Uninstalling pip-18.1:
      Successfully uninstalled pip-18.1
Successfully installed pip-18.0

そして再度pipenv installすると

$ pipenv install bs4
Installing bs4...
Requirement already satisfied: bs4 in /home/user/.local/share/virtualenvs/piptest-G3GN52P4/lib/python3.7/site-packages (0.0.1)
Requirement already satisfied: beautifulsoup4 in /home/user/.local/share/virtualenvs/piptest-G3GN52P4/lib/python3.7/site-packages (from bs4) (4.6.3)

Adding bs4 to Pipfile's [packages]...
Pipfile.lock not found, creating...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
Updated Pipfile.lock (8cf921)!
Installing dependencies from Pipfile.lock (8cf921)...
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 2/2 — 00:00:00
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.

問題なくできました。 pip18.1にPipenvが対応するまではこのワークアラウンドで凌ぐことにします。

※文頭に追記した通り、2018/10/10現在は解消されています。


Sponsored Link