[英]How to install a pip package locally in Dockerfile?
I'm trying to clone a python package from github and then install it locally with pip -e
as follows: 我正在尝试从github克隆一个python软件包,然后使用
pip -e
在本地安装它,如下所示:
RUN git clone https://github.com/st4lk/django-rest-social-auth.git
RUN pip install -e django-rest-social-auth
but I get error message: 但我收到错误消息:
Step 6 : RUN pip install -e django-rest-social-auth
---> Running in 8943e688573f
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
load_entry_point('pip==1.5.6', 'console_scripts', 'pip')()
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 356, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2476, in load_entry_point
return ep.load()
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2190, in load
['__name__'])
File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 74, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/lib/python2.7/dist-packages/pip/vcs/mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "/usr/lib/python2.7/dist-packages/pip/download.py", line 25, in <module>
from requests.compat import IncompleteRead
ImportError: cannot import name IncompleteRead
What's wrong? 怎么了?
Full Dockerfile
for reference: 完整的
Dockerfile
供参考:
FROM debian:jessie
ADD . /workflows
# Install dependencies
RUN apt-get update && apt-get install -y \
git \
python-django \
python-psycopg2 \
python-django-celery \
rabbitmq-server \
python-django-jsonfield \
python-pip
RUN pip install djangorestframework \
python-social-auth
RUN git clone https://github.com/st4lk/django-rest-social-auth.git
RUN pip install -e django-rest-social-auth
# Get everything ready and run
RUN python /workflows/manage.py validate
RUN python /workflows/manage.py collectstatic --noinput
CMD python /workflows/manage.py runserver 0.0.0.0:8000
The IncompleteRead
name was removed from requests.compat
in https://github.com/kennethreitz/requests/commit/47d0517d66e8cf5832768262221f0357ae134ad1 . 该
IncompleteRead
名字从取出requests.compat
在https://github.com/kennethreitz/requests/commit/47d0517d66e8cf5832768262221f0357ae134ad1 。
After completing this section of your Dockerfile... 在完成Dockerfile的这一部分之后...
RUN apt-get update && apt-get install -y \
git \
python-django \
python-psycopg2 \
python-django-celery \
rabbitmq-server \
python-django-jsonfield \
python-pip
You have Requests version 2.4.3 and pip 1.5.6. 您有请求版本2.4.3和点1.5.6。 Both of these are quite old.
这两个都是很老的。 When you next run
pip install
... 下次运行
pip install
...
RUN pip install djangorestframework \
python-social-auth
...this upgrades your Requests package to 2.9.1, which is no longer compatible with the old version of pip
installed in your image. ...这会将您的请求包升级到2.9.1,该包不再与映像中安装的旧版
pip
兼容。
You can avoid this problem by installing a newer version of pip
. 您可以通过安装较新版本的
pip
来避免此问题。 Rather than installing the python-pip
package, just use easy_install
to acquire pip
: 无需安装
python-pip
软件包,只需使用easy_install
来获取pip
:
RUN apt-get update && apt-get install -y \
git \
python-django \
python-psycopg2 \
python-django-celery \
rabbitmq-server \
python-django-jsonfield
RUN easy_install pip
This will install the latest version of pip
, which will operate successfully with the version of Requests installed required by your subsequent Python module installs. 这将安装最新版本的
pip
,它将与后续Python模块安装所需的请求版本一起成功运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.