Home Backend Development Python Tutorial Build your own pip source in Python environment

Build your own pip source in Python environment

Mar 02, 2017 pm 05:30 PM

1. Install the pip2pi tool:

##

pip install pip2pi
Copy after login

or:

git clone https://github.com/wolever/pip2pi
cd pip2pi
python setup.py install
Copy after login

2. Create a warehouse to store the software package:

mkdir /opt/python/soft/pypi.jb51.net
Copy after login

3. Download the software package And create an index:

Download a software package individually

pip2tgz /opt/python/soft/pypi.jb51.net/ routes==1.12.3
Copy after login

Download software packages in batches:

pip2tgz /opt/python/soft/pypi.jb51.net/ -r list/requirements.txt
Copy after login

Create index:

dir2pi /opt/python/soft/pypi.jb51.net/
Copy after login

Update index:

pip2acmeco uliweb=0.2.6 
pip2acmeco -r list/requirements.txt
Copy after login

4. Configure the web side with nginx:

Nginx server adds virtual host configuration:

server {
  listen 80;
  server_name pypi.jb51.net;
  root /opt/python/soft/pypi.jb51.net;
  location /{
   autoindex on;
   autoindex_exact_size off; #显示文件的大小
   autoindex_localtime on; #显示文件时间
   #limit_rate_after 5m; #5分钟后下载速度限制为200k
   limit_rate 200k;
  }
access_log logs/pypi.jb51.net.access.log main;
}
Copy after login

At this point, you have configured your own private pypi. When you need any software packages, you can just get them and put them in your own pypi;

In the same way, you can also package your own projects.

5. How to better use pypi source:

For example, install uliweb

pip install --index-url=http://www.php.cn/ uliweb
Copy after login

or


pip install -i uliweb
Copy after login

Is this very troublesome? Do you want to use your own pypi source by default? Well, it’s given to you here I have thought of a method:

Create the ~/.pip/pip.conf file under Linux. The file content is as follows

[global]
index-url = http://www.php.cn/
Copy after login

If It is a windows environment, create: %HOMEPATH%\pip\pip.ini

The content is the same as under Linux above.

We also recommend several better domestic pypi sources:

http://pypi.douban.com 豆瓣
 
http://pypi.hustunique.com 华中理工大学
 
http://pypi.sdutlinux.org 山东理工大学
 
http://pypi.mirrors.ustc.edu.cn 中国科学技术大学
Copy after login

PS: There are two ways to modify the source used by easy_install and pip
(from the mirror source e.pypi.python.org on Linux Download and install requests as an example):

Command mode: For one-time use, temporary modification

easy_install

easy_install -i http://e.pypi.python.org/simple requests
Copy after login

pip

pip install requests -i http://e.pypi.python.org/simple
Copy after login

Note: 1. The source path must include the /simple part; 2. When using pip, the -i parameter should be placed after install xxx

Modify (if not, create) the configuration file of easy_install/pip

easy_install: Write the following content in the ~/.pydistutils.cfg configuration file:

[easy_install]
index_url = http://e.pypi.python.org/simple
Copy after login

pip: Write in the ~/.pip/pip.conf configuration file:

[global]
index-url = http://e.pypi.python.org/simple
Copy after login


For more articles related to building your own pip source in the Python environment, please pay attention to the PHP Chinese website!


Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to solve the permissions problem encountered when viewing Python version in Linux terminal? How to solve the permissions problem encountered when viewing Python version in Linux terminal? Apr 01, 2025 pm 05:09 PM

Solution to permission issues when viewing Python version in Linux terminal When you try to view Python version in Linux terminal, enter python...

How to efficiently copy the entire column of one DataFrame into another DataFrame with different structures in Python? How to efficiently copy the entire column of one DataFrame into another DataFrame with different structures in Python? Apr 01, 2025 pm 11:15 PM

When using Python's pandas library, how to copy whole columns between two DataFrames with different structures is a common problem. Suppose we have two Dats...

How to teach computer novice programming basics in project and problem-driven methods within 10 hours? How to teach computer novice programming basics in project and problem-driven methods within 10 hours? Apr 02, 2025 am 07:18 AM

How to teach computer novice programming basics within 10 hours? If you only have 10 hours to teach computer novice some programming knowledge, what would you choose to teach...

What are regular expressions? What are regular expressions? Mar 20, 2025 pm 06:25 PM

Regular expressions are powerful tools for pattern matching and text manipulation in programming, enhancing efficiency in text processing across various applications.

How to avoid being detected by the browser when using Fiddler Everywhere for man-in-the-middle reading? How to avoid being detected by the browser when using Fiddler Everywhere for man-in-the-middle reading? Apr 02, 2025 am 07:15 AM

How to avoid being detected when using FiddlerEverywhere for man-in-the-middle readings When you use FiddlerEverywhere...

How does Uvicorn continuously listen for HTTP requests without serving_forever()? How does Uvicorn continuously listen for HTTP requests without serving_forever()? Apr 01, 2025 pm 10:51 PM

How does Uvicorn continuously listen for HTTP requests? Uvicorn is a lightweight web server based on ASGI. One of its core functions is to listen for HTTP requests and proceed...

What are some popular Python libraries and their uses? What are some popular Python libraries and their uses? Mar 21, 2025 pm 06:46 PM

The article discusses popular Python libraries like NumPy, Pandas, Matplotlib, Scikit-learn, TensorFlow, Django, Flask, and Requests, detailing their uses in scientific computing, data analysis, visualization, machine learning, web development, and H

How to dynamically create an object through a string and call its methods in Python? How to dynamically create an object through a string and call its methods in Python? Apr 01, 2025 pm 11:18 PM

In Python, how to dynamically create an object through a string and call its methods? This is a common programming requirement, especially if it needs to be configured or run...

See all articles