python本地镜像源搭建_搭建本地pypi源

注意事项

千万不要百度,百度出来没有好东西

看官方文档,官方文档

这个工具只支持python 3.6 以上

安装虚拟环境

切换到你想要放置的目录再做一下步操作

python3.6 -m venv bandersnatch 或者 virtualenv --python=python3.6 bandersnatch

source bandersnatch/bin/activate

pip3.6 install bandersnatch

Quick start

官方原话

Run bandersnatch mirror - it will create an empty configuration file for you in /etc/bandersnatch.conf].

Review /etc/bandersnatch.conf and adapt to your needs.

Run bandersnatch mirror again. It will populate your mirror with the current status of all PyPI packages. Current mirror package size can be seen here: https://pypi.org/stats/

A blacklist or whitelist can be created to cut down your mirror size. You might want to Analyze PyPI downloads to determine which packages to add to your list.

Run bandersnatch mirror regularly to update your mirror with any intermediate changes.

配置文件唯一需要修改的就是你的包存放目录directory = /data/storage/pypi/ 修改这个参数

镜像源如果有问题可以修改为国内的,但是没试过,直接用的官方源站,第一次同步都会耗费时间

Web Server

Configure your webserver to serve the web/ sub-directory of the mirror. For nginx it should look something like this

server {

listen 127.0.0.1:80;

server_name ;

root /web;

autoindex on;

charset utf-8;

}

Note that it is a good idea to have your webserver publish the HTML index files correctly with UTF-8 as the charset. The index pages will work without it but if humans look at the pages the characters will end up looking funny.

Make sure that the webserver uses UTF-8 to look up unicode path names. nginx gets this right by default - not sure about others.

Cron jobs

根据实际情况来填写,我的python3.6是编译的,需要引入lib库

00 0 * * * bandersnatch mirror >/dev/null 2>&1

设置方法

临时使用:

例如:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pandas,这样就会从清华镜像安装pandas库。

永久修改,一劳永逸:

Linux下,修改 ~/.pip/pip.conf (没有就创建一个文件夹及文件。文件夹要加“.”,表示是隐藏文件夹)

内容如下:

[global]

index-url = https://pypi.tuna.tsinghua.edu.cn/simple

[install]

trusted-host = https://pypi.tuna.tsinghua.edu.cn

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值