使用pip2pi搭建自己的pip源

最近在搭建python环境时遇到断网的情况,往往模块下载到一半就停了,虽然换成国内的镜像也可以勉强解决问题,但是还是升起了搭建一个本地的pip源,不怕断网。

 

步骤如下:

1.安装python 3.5.4

2.安装pip2pi

pip install pip2pi

3.安装nginx

yum install nginx

可能会遇到错误说没有可用软件包 nginx

解决方案:(参考https://www.cnblogs.com/jackylee92/p/6371366.html

  安装epel;

  去epel官网: http://fedoraproject.org/wiki/EPEL下载;这里面东西有点多难找;

  直接贴出下载的地址http://dl.fedoraproject.org/pub/在这里面找;

  我的是centos7 64位;在目录中http://dl.fedoraproject.org/pub/epel/7/x86_64/e/

  下载正确版本epel的地址为:http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm

  下载后安装rpm -ivh epel-release-7-9.noarch.rpm

  

  安装成功后执行yum install nginx即可;

4.配置nginx


server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  _;
        root /opt/python/soft/pypi;

        include /etc/nginx/default.d/*.conf;

        location / {
        autoindex on;
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }


5.下载模块

[root@localhost docker] pip2tgz '/opt/python/soft/pypi' -r '/home/docker/packages/requirements.txt' 

6.建立索引

[root@localhost docker] dir2pi /opt/python/soft/pypi/

7.启动nginx
[root@localhost docker] nginx

8.使用本地pip源
pip install --no-cache-dir -i http://127.0.0.1/simple --trusted-host 127.0.0.1 -r requirements.txt
参考:Python环境下使用pip2pi搭建属于自己的pip源

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值