搭建私有pip源

2023-05-16



# yum -y install python-pip

 

2. 用pip安装pypiserver

# pip install pypiserver

 

3. 建立目录

# mkdir /home/pypi/packages

 

4. 启动服务

# nohup pypi-server -p 8080 /home/pypi/packages &

#备注:确保端口不冲突,8888端口没有被使用。

 

5. 将一个包下载,装到packages下面,比如下载simplejson 的包

# pip -q install –no-deps -i http://pypi.python.org/simple -d /home/pypi/packages simplejson

如果想把所有的包下载下来,只能一个一个包( http://pypi.python.org/simple  上面的)下载了。

##备注:这一步没有下载成功,只是手工拷贝了一些pypi包到/home/pypi/packages下。如下:

[root@puppetmaster packages]# pwd
/home/pypi/packages
[root@puppetmaster packages]# ls
pymongo-2.6.3.tar.gz    tornado-2.4.1.tar.gz

 

6. 如果要升级的话,下面的命令可以升级目录下的所有包

# pypi-server -U /home/pypi/packages/

 

7. 为了方便建立索引个,我安装了一个包 pip2pi

# pip install pip2pi

现在可以使用 dir2pi 建立索引了,用

# dir2pi /home/pypi/packages

备注:创建索引,生产simple文件,如下:

[root@puppetmaster packages]# pwd
/home/pypi/packages
[root@puppetmaster packages]# ls
pymongo-2.6.3.tar.gz  simple  tornado-2.4.1.tar.gz

 

8. 安装Nginx,可以用来做负载均衡。

# yum -y install nginx

配置文件(pypi源机器是 pypi1.hy01):

server {
     listen 80;
     server_name pypi.hy01.internal.wandoujia.com;
 
     access_log /home/work/nginx/logs/pypi_wandoujia.access.log main;
     error_log /home/work/nginx/logs/pypi_wandoujia.error.log;
 
     location / {
         proxy_pass http://pypi1.hy01:8080/;
     }
}

 如果不采用如上方法,则配置一个nginx服务,内容如下:

[root@puppetmaster sites-enabled]# pwd
/usr/local/webserver/nginx/sites-enabled
[root@puppetmaster sites-enabled]# cat pypi.nginx.conf
server {
    listen 8888;
    server_name 192.168.90.163;
    location / {
        index index.php;
        root /home/pypi/packages;
    }
    location ~ \.php$ {
        fastcgi_pass  unix:/tmp/php-cgi.sock;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /home/www-data/www$fastcgi_script_name;
        send_timeout 300;
        fastcgi_buffers 8 256k;
        include /usr/local/webserver/nginx/conf/fastcgi_params;
    }
}
[root@puppetmaster sites-enabled]#

9. 最后装包用

# pip install $package_name -i http://pypi.hy01.internal.wandoujia.com/simple/

备注:我的方法是,如下:

[root@kooxoo90-170 sites-enabled]#  pip install pymongo -i http://192.168.90.163:8888/simple
/usr/lib/python2.6/site-packages/setuptools-1.4.2-py2.6.egg/pkg_resources.py:979: UserWarning: /root/.python-eggs is writable by group/others and vulnerable to attack when used with get_resource_filename. Consider a more secure location (set with .set_extraction_path or the PYTHON_EGG_CACHE environment variable).
Collecting pymongo
  The repository located at 192.168.90.163 is not a trusted or secure host and is being ignored. If this repository is available via HTTPS it is recommended to use HTTPS instead, otherwise you may silence this warning and allow it anyways with '--trusted-host 192.168.90.163'.
  Could not find a version that satisfies the requirement pymongo (from versions: )
No matching distribution found for pymongo
[root@kooxoo90-170 sites-enabled]#

解决方法:

[root@kooxoo90-170 sites-enabled]#  pip install pymongo -i http://192.168.90.163:8888/simple --trusted-host 192.168.90.163
/usr/lib/python2.6/site-packages/setuptools-1.4.2-py2.6.egg/pkg_resources.py:979: UserWarning: /root/.python-eggs is writable by group/others and vulnerable to attack when used with get_resource_filename. Consider a more secure location (set with .set_extraction_path or the PYTHON_EGG_CACHE environment variable).
Collecting pymongo
  Downloading http://192.168.90.163:8888/packages/pymongo-2.6.3.tar.gz (324kB)
    100% |████████████████████████████████| 327kB 21.7MB/s
Building wheels for collected packages: pymongo
  Running setup.py bdist_wheel for pymongo
  Stored in directory: /root/.cache/pip/wheels/90/18/ee/1ec1dfc8151aab48c3c60917fd81a160a55bcdb269cf95c132
Successfully built pymongo
Installing collected packages: pymongo
Successfully installed pymongo-2.6.3
[root@kooxoo90-170 sites-enabled]# pip freeze  | grep pymongo                              
/usr/lib/python2.6/site-packages/setuptools-1.4.2-py2.6.egg/pkg_resources.py:979: UserWarning: /root/.python-eggs is writable by group/others and vulnerable to attack when used with get_resource_filename. Consider a more secure location (set with .set_extraction_path or the PYTHON_EGG_CACHE environment variable).
pymongo==2.6.3
[root@kooxoo90-170 sites-enabled]#


原文url:http://www.nosa.me/2014/11/08/%E6%90%AD%E5%BB%BApypi-%E6%9C%AC%E5%9C%B0%E6%BA%90/





转载于:https://blog.51cto.com/tenderrain/1696119

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

搭建私有pip源 的相关文章

随机推荐

  • 从ELK到EFK

    背景 作为中国最大的在线教育站点 xff0c 目前沪江日志服务的用户包含沪江网校 xff0c 交易 xff0c 金融 xff0c CCtalk xff08 直播平台 xff09 等多个部门的多个产品的日志搜索分析业务 xff0c 每日产生的
  • 证明:实对称矩阵中,属于不同特征值的特征向量相互正交

    2019独角兽企业重金招聘Python工程师标准 gt gt gt 证明 xff1a 实对称矩阵中 xff0c 属于不同特征值的特征向量相互正交 设AP 61 1P xff0c AP 61 2P xff0c 其中A为实对称矩阵 xff0c
  • 宝塔面板一键docker部署

    2019独角兽企业重金招聘Python工程师标准 gt gt gt 推荐 xff1a 宝塔面板一键docker部署 0 购买服务器 1 安装docker root 64 VM 0 2 centos curl fsSL https get d
  • 异步I/O Asynchronous I/O

    原帖地址 xff1a http www ibm com developerworks cn linux l async AIO 简介 Linux 异步 I O 是 Linux 内核中提供的一个相当新的增强 它是 2 6 版本内核的一个标准特
  • Trapping Rain Water II

    Given n x m non negative integers representing an elevation map 2d where the area of each cell is 1 x 1 compute how much
  • QT- label实现滚动字幕 (跑马灯)效果 -像素级

    QT label滚动字幕 原理代码完整源码 43 部件提升 想通过QSS实现更多效果的请搜索QT自带帮助文档 Qt Style Sheets Examples xff0c 使用样式表来定制程序界面 原理 让label字母滚动起来的原理很简单
  • matlab练习程序(TV模型图像修复)

    曾经想要实现过Bertalmio图像修复算法 xff0c 无奈自身实力不够 xff0c 耗费两天时间也没能实现 昨天博客上有人问到TV模型 xff0c 这个模型我过去是没听说过的 xff0c 于是就找来相关论文研究了一下 xff0c 发现T
  • M4——GPIO配置

    1 GPIO 简述 通用输入输出 General Purpose Input Output 的简称 xff0c 就是芯片引脚可以通过他们输出高电平或者低电平 xff0c 也可以通过他们读取引脚的电平状态 以STM32F407ZGT6芯片为例
  • linux 查看服务器序列号(S/N)

    root 64 node1 dmidecode t 查看支持的参数 dmidecode option requires an argument 39 t 39 Type number or keyword expected Valid ty
  • Apache 中文显示乱码的问题

    用Apache 2 2发布一个html网页 xff0c 访问时发现网页中的中文全部显示乱码 之前在IIS上发布显示很正常 xff0c 网页本身编码应该是没问题的 查看源代码确定html文档编码为GB2312 在 etc httpd conf
  • 对centos进行一些个性化设置(如alias等)

    为什么80 的码农都做不了架构师 xff1f gt gt gt 一 xff1a linux xff08 centos5 10 xff09 中alias的设置 amp 常用 查询 xff1a 查看当前系统的所有alias shell gt a
  • Linux编程之有限状态机FSM的理解与实现

    有限状态机 xff08 finite state machine xff09 简称FSM xff0c 表示有限个状态及在这些状态之间的转移和动作等行为的数学模型 xff0c 在计算机领域有着广泛的应用 FSM是一种逻辑单元内部的一种高效编程
  • 用Nohup命令让Linux下的程序真正在后台执行(转载)

    Unix Linux 下一般想让某个程序在后台运行 xff0c 很多都是使用 amp 在程序结尾来让程序自动运行 比如我们要运行 mysql 在后台 xff1a usr local mysql bin mysqld safe user 61
  • iOS开发-关于自定义控件很值得一看的文章( 四)

    2019独角兽企业重金招聘Python工程师标准 gt gt gt 我么知道 Objective xff0d C 是采用 消息机制 xff08 messaging xff09 调用方法的 xff0c 例如我们调用 UIView 的 init
  • POSIX 消息队列相关问题

    一 查看和删除消息队列 要想看到创建的posix消息队列 xff0c 需要在root用户下执行以下操作 xff1a mkdir dev mqueue mount t mqueue none dev mqueue 删除队列使用 rm 命令即可
  • HDU-时间挑战 树状数组

    这题好像是POJ的一道原题 首先这题我们能够确定如果一条线段被另外一条线段所包含的话 xff0c 那么那条包含它的线段的左端点一定小于或者等于这个线段 于是我们按照左端点从小到大排序 xff0c 左端点相同按照右端点从大到小排序 xff0c
  • Linux-添加systemd自启动服务 + 内网穿透模块NPC自启动(x96-coreelec squashfs固件修改)

    添加服务及修改coreelec固件 System unit简介配置服务文件 xff1a systemd service Unit 部分 xff1a 配置服务的基础信息 Service 部分 xff1a 配置服务的启动和操作 Install
  • PostgreSQL的实践一:初识

    简介和认知 发音 post gres q l 服务 xff08 server xff09 一个操作系统中可以启动多个postgres服务 每个服务由多个进程组成 xff0c 为首的进程名为postmaster 每个服务要占用一个端口 xff
  • android真机怎么使用虚拟串口,怎么用小米手机调试我写的android程序

    怎么用小米手机调试我写的android程序以下文字资料是由 历史新知网www lishixinzhi com 小编为大家搜集整理后发布的内容 xff0c 让我们赶快一起来看一下吧 xff01 怎么用小米手机调试我写的android程序 下个
  • 搭建私有pip源

    yum y install python pip 2 用pip安装pypiserver pip install pypiserver 3 建立目录 mkdir home pypi packages 4 启动服务 nohup pypi ser