mitsuhiko / pipsi

pip script installer
Other
2k stars 133 forks source link

Struggles with Installing Pipenv through Pipsi and Pyenv #173

Open arnavb opened 6 years ago

arnavb commented 6 years ago

I'm trying to install Pipenv through Pipsi, but I'm having issues, as evident:

$ pyenv global
3.6.6

$ python -m pip install --upgrade pip
Requirement already up-to-date: pip in /home/ubuntu/.pyenv/versions/3.6.6/lib/python3.6/site-packages (18.0)

$ curl https://raw.githubusercontent.com/mitsuhiko/pipsi/master/get-pipsi.py | python
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  6577  100  6577    0     0  66319      0 --:--:-- --:--:-- --:--:-- 66434
Installing pipsi
sys.executable=/home/ubuntu/.pyenv/versions/3.6.6/bin/python sys.real_prefix=None executable=/home/ubuntu/.pyenv/versions/3.6.6/bin/python
Collecting pipsi
  Downloading https://files.pythonhosted.org/packages/4e/16/297caa009ac37bb52a31ed8a76ee50fe373794f32a6ec7a227d7af65e15b/pipsi-0.9.tar.gz
Collecting Click (from pipsi)
  Downloading https://files.pythonhosted.org/packages/34/c1/8806f99713ddb993c5366c362b2f908f18269f8d792aff1abfd700775a77/click-6.7-py2.py3-none-any.whl (71kB)
    100% |████████████████████████████████| 71kB 3.5MB/s 
Collecting virtualenv (from pipsi)
  Downloading https://files.pythonhosted.org/packages/b6/30/96a02b2287098b23b875bc8c2f58071c35d2efe84f747b64d523721dc2b5/virtualenv-16.0.0-py2.py3-none-any.whl (1.9MB)
    100% |████████████████████████████████| 1.9MB 7.4MB/s 
Installing collected packages: Click, virtualenv, pipsi
  Running setup.py install for pipsi ... done
Successfully installed Click-6.7 pipsi-0.9 virtualenv-16.0.0
You are using pip version 10.0.1, however version 18.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Installed pipsi binary in /home/ubuntu/.local/bin
Added /home/ubuntu/.local/bin to the PATH environment variable in /home/ubuntu/.bashrc
Open a new terminal to use pipsi
pipsi is now installed.

$ source ~/.bashrc

$ pipsi install pipenv
Running virtualenv with interpreter /home/ubuntu/.local/venvs/pipsi/bin/python
Using base prefix '/home/ubuntu/.pyenv/versions/3.6.6'
New python executable in /home/ubuntu/.local/venvs/pipenv/bin/python
Installing setuptools, pip...
  Complete output from command /home/ubuntu/.local/venvs/pipenv/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip:
  Traceback (most recent call last):
  File "", line 1, in 
  File "", line 971, in _find_and_load
  File "", line 955, in _find_and_load_unlocked
  File "", line 656, in _load_unlocked
  File "", line 626, in _load_backward_compatible
  File "/usr/share/python-virtualenv/pip-1.5debian1-py2.py3-none-any.whl/pip/__init__.py", line 9, in 
  File "", line 971, in _find_and_load
  File "", line 955, in _find_and_load_unlocked
  File "", line 656, in _load_unlocked
  File "", line 626, in _load_backward_compatible
  File "/usr/share/python-virtualenv/pip-1.5debian1-py2.py3-none-any.whl/pip/log.py", line 9, in 
  File "", line 971, in _find_and_load
  File "", line 955, in _find_and_load_unlocked
  File "", line 656, in _load_unlocked
  File "", line 626, in _load_backward_compatible
  File "/usr/share/python-virtualenv/pip-1.5debian1-py2.py3-none-any.whl/pip/_vendor/pkg_resources.py", line 1423, in 
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'
----------------------------------------
...Installing setuptools, pip...done.
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 2339, in 
    main()
  File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 825, in main
    symlink=options.symlink)
  File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 993, in create_environment
    install_wheel(to_install, py_executable, search_dirs)
  File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 961, in install_wheel
    'PIP_NO_INDEX': '1'
  File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 903, in call_subprocess
    % (cmd_desc, proc.returncode))
OSError: Command /home/ubuntu/.local/venvs/pipenv/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip failed with error code 1
Failed to create virtualenv.  Aborting.

As evident, there are some issues here, the first being that the correct pip instance isn't being used when installing pipsi (bold text), and the second problem being that the virtualenv cannot be created for installing pipenv in. I'm not entirely sure if these two issues are related or not, but I'm including the information for the sake of completeness.

How do I fix this?

00willo commented 6 years ago

@arnavb I already have pipenv installed via brew and I don't want to mess with that now, but I've had success with installing tools that require my pyenv version by doing it this way. Could you try it this way.

Let's first assume that you want to do this, I typically want my pyenv versions always running a newer pip so I don't have to do this every virtualenv.

pyenv install 3.6.6
# enable pyenv version to update pip etc
pyenv global 3.6.6
pip install --upgrade pip setuptools
# disable it to back on the system default python
pyenv global system

Then it'd simply become

pipsi install --python $PYENV_ROOT/versions/3.6.6/bin/python pipenv

This way you also don't need to activate that specific version of pyenv to run the tools, but this may not be what you want.

I've only used pipenv briefly, so this may not be a great, but at first glance I think this would work ok assuming you're not looking for a specific version of pipenv in any specific pyenv virtualenv. Don't know, mileage may vary on all, so you should probably test it out.