how can i use pip with pypy installed from launchpad?

旧巷老猫 提交于 2019-11-29 20:38:04
xubuntix

Quoting (with minor changes) from here the pypy website:

If you want to install 3rd party libraries, the most convenient way is to install pip:

$ curl -O https://bootstrap.pypa.io/get-pip.py
$ ./pypy-2.1/bin/pypy get-pip.py
$ ./pypy-2.1/bin/pip install pygments  # for example

In order to use it nicely, you might want to add an alias into e.g. ~/.bashrc:

alias pypy_pip='./pypy-2.1/bin/pip'

Where the actual pip executable is located has to be taken from the output of pypy get-pip.py

To keep a separate installation, you might want to create a virtualenv for PyPy. Within the virtualenv, you can then just run pip install whatever and it will install it for PyPy. When you create a virtualenv, it automatically installs pip for you.

Otherwise, you will need to work out where PyPy will import from and install distribute and pip in one of those locations. pip's installer should do this automatically when run with PyPy. Be careful with this option - if it decides to install in your system Python directories, it could break other things.

if you want to use pip with pypy:

pypy -m pip install [package]

pip is included with pypy so just target pip with the -m flag

The problem with pip installing from the pypy (at least when installing pypy via apt-get) is that it is installed into the system path:

$ whereis pip
pip: /usr/local/bin/pip /usr/bin/pip

So after such install, pypy pip is executed by default (/usr/local/bin/pip) instead of the python pip (/usr/bin/pip) which may break subsequent updates of the whole Ubuntu.

The problem with virtualenv is that you should remember where and what env you created.

Convenient alternative solution is conda (miniconda), which manages not only python deployments: http://conda.pydata.org/miniconda.html. Comparison of conda, pip and virtualenv: http://conda.pydata.org/docs/_downloads/conda-pip-virtualenv-translator.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!