#安裝pip工具 root@ubuntu:/#apt-get install python-pip #安裝pip2py工具 root@ubuntu:/#pip install pip2pi #建立保存pip源的目錄 root@ubuntu:/#mkdir /export/pypi #將相關pip源文件放置到目錄下 root@ubuntu:/# cd /export/pypi #同步pip源到本地 #批量下載 root@ubuntu:/export/pypi#pip2tgz path -r requirements.txt #單個下載 root@ubuntu:/export/pypi# pip2tgz path package==1.0 #重建pip索引 root@ubuntu:/export/pypi# cd .. root@ubuntu:/export# dir2pi pypi/ #安裝apache root@ubuntu:/#apt-get install apache2 #將pypi掛到web server下 root@ubuntu:/export# cd /var/www/html/ root@ubuntu:/var/www/html# ln -s /export/pypi pypi #啓動apache2 root@ubuntu:/var/www/html# /etc/init.d/apache2 start #ok,搭建完成
#能夠通入以下配置使用本地pip源 #配置easy_install使用本地pip源,若是沒有文件/root/.pydistutils.cfg,則建立。 echo "[easy_install]" > /root/.pydistutils.cfg echo "index-url = http://本地ip地址/pypi/simple" >> /root/.pydistutils.cfgeasy_install pip #配置pip使用pip本地源 mkdir /root/.pip echo "[global]" > /root/.pip/pip.conf echo "index-url = http://本地ip地址/pypi/simple" >> /root/.pip/pip.conf echo "trusted-host = 本地ip地址" >> /root/.pip/pip.conf
+ sudo https_proxy= LANG=C chroot ./fsroot pip install docker-py==1.6.0 Collecting docker-py==1.6.0 Downloading https://files.pythonhosted.org/packages/31/cb/c70c10e459d274976a9b64a05d231cb6e05f7e1826f9ab0548c4748ba348/docker-py-1.6.0.tar.gz (63kB) Collecting requests>=2.5.2 (from docker-py==1.6.0) Downloading https://files.pythonhosted.org/packages/51/bd/23c926cd341ea6b7dd0b2a00aba99ae0f828be89d72b2190f27c11d4b7fb/requests-2.22.0-py2.py3-none-any.whl (57kB) Collecting six>=1.4.0 (from docker-py==1.6.0) Downloading https://files.pythonhosted.org/packages/65/26/32b8464df2a97e6dd1b656ed26b2c194606c16fe163c695a992b36c11cdf/six-1.13.0-py2.py3-none-any.whl Collecting websocket-client>=0.32.0 (from docker-py==1.6.0) Downloading https://files.pythonhosted.org/packages/29/19/44753eab1fdb50770ac69605527e8859468f3c0fd7dc5a76dd9c4dbd7906/websocket_client-0.56.0-py2.py3-none-any.whl (200kB) Exception:
從上面能夠看出,沒有設置成功的話,其訪問的路徑是:html
https://files.pythonhosted.org/packages
設置成功的話,其訪問的路徑爲:python
Looking in indexes: http://172.17.0.2/pypi/simple Collecting docker-py==1.6.0 Downloading http://172.17.0.2/pypi/simple/docker-py/docker-py-1.6.0.tar.gz (63kB) Collecting requests>=2.5.2 (from docker-py==1.6.0) Downloading http://172.17.0.2/pypi/simple/requests/requests-2.20.1-py2.py3-none-any.whl (57kB) Collecting six>=1.4.0 (from docker-py==1.6.0) Downloading http://172.17.0.2/pypi/simple/six/six-1.11.0-py2.py3-none-any.whl
會有以下顯示:web
Looking in indexes: http://172.17.0.2/pypi/simple