Solve the problem that pip install is stuck

  • 2021-09-16 07:40:16
  • OfStack

Don't say anything, tears come from the ineffective dog with deep resentment.

"Running Environment"

1. Install flask-mongoengine with pip under ubuntu;

2. pip has risen to the highest version. Your sister, after the old version of ctrl + c, you can still know where it is broken, and the new one does not even have an p directly;

3. The source of Douban was used to accelerate, and an agent that can climb over the wall was added during installation, but the eggs were merged;

4, stuck, how to describe the error prompt? There are no related problems in google at home and abroad.

5. Can Extremely slow pypi package retrieval with i. e. pip be described in this way?

6. Python 2.7. 10

"Error Prompt"

Do you still want an error prompt? Hint your sister! There is no error prompt after it is stuck.

(venv)➜ flask-mongoengine-0.7.5 pip install flask-mongoengine --proxy=http://proxy.xxx.com:80 -v
Collecting flask-mongoengine
1 location(s) to search for versions of flask-mongoengine:
* http://pypi.douban.com/simple/flask-mongoengine/
Getting page http://pypi.douban.com/simple/flask-mongoengine/
Starting new HTTP connection (1): proxy.corp.qihoo.net
"GET http://pypi.douban.com/simple/flask-mongoengine/ HTTP/1.1" 301 178
"GET http://pypi.doubanio.com/simple/flask-mongoengine/ HTTP/1.1" 200 1068
Analyzing links from page http://pypi.doubanio.com/simple/flask-mongoengine/
Found link http://pypi.doubanio.com/packages/f3/46/e527ea37dd53e5addae8167c2e5850029c7be98add465928cac7d1d10d0e/flask-mongoengine-0.7.5.tar.gz#md5=e207998d4ab5237582c4983cd18ab484 (from http://pypi.doubanio.com/simple/flask-mongoengine/), version: 0.7.5

Using version 0.7.5 (newest of versions: 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7.0, 0.7.1, 0.7.3, 0.7.4, 0.7.5)
"GET http://pypi.doubanio.com/packages/f3/46/e527ea37dd53e5addae8167c2e5850029c7be98add465928cac7d1d10d0e/flask-mongoengine-0.7.5.tar.gz HTTP/1.1" 200 110621
Downloading http://pypi.doubanio.com/packages/f3/46/e527ea37dd53e5addae8167c2e5850029c7be98add465928cac7d1d10d0e/flask-mongoengine-0.7.5.tar.gz (110kB)
Downloading from URL http://pypi.doubanio.com/packages/f3/46/e527ea37dd53e5addae8167c2e5850029c7be98add465928cac7d1d10d0e/flask-mongoengine-0.7.5.tar.gz#md5=e207998d4ab5237582c4983cd18ab484 (from http://pypi.doubanio.com/simple/flask-mongoengine/)
100% 112kB 44.5 MB/s
Running setup.py (path:/tmp/pip-build-5h86uM/flask-mongoengine/setup.py) egg_info for package flask-mongoengine
Running command python setup.py egg_info
# It's stuck here. It doesn't move
^CCleaning up...
Operation cancelled by user

[Cause of problem]

Manual execution, found broken in the sock, ssl to establish that block of code, in order to download things;

Clearly specified the source of douban, but it is still very slow;

There is only one truth. The library flask-mongoengine is very cheap when it is installed, and it installs other libraries by itself (here, the author calls it twice installation). The source of the second installation is [https://pypi.python.org] that comes with python, which is stuck.

[Solution]

The author did not find a more graceful way to solve the problem, in pip. conf did not set 2 times when installing the source of the method, good English can be studied under the pip use of the official documents.

1. Edit file /usr/lib/python2.7/dist-packages/setuptools/package_index. py under root user;

2. Plug in the advertisement: Students who use virtualenv should modify the./lib/python2.7/site-packages/setuptools/package_index. py in the venv directory.

3. Skip to line 261 and hard-code the value of index_url to read as follows:


 class PackageIndex(Environment):
  """A distribution index that scans web pages for download URLs"""
  def __init__(
    self, index_url="http://pypi.douban.com/simple", hosts=('*',),
    ca_bundle=None, verify_ssl=True, *args, **kw
    ):
   Environment.__init__(self,*args,**kw)
   index_url = "http://pypi.douban.com/simple"
   self.index_url = index_url + "/"[:not index_url.endswith('/')]

[Implementation Results]

Execute the command pip install flask-mongoengine, and post a prompt after success (holy shit! )


...
done
 Removing source in /tmp/pip-build-ZSaB9M/flask-mongoengine
Successfully installed WTForms-2.1 flask-mongoengine-0.7.5 flask-wtf-0.12
Cleaning up...

"fck"

csdn made markdown this SX play should son, insert an code block in the middle of numbered list, the serial number after the code block is not right, it is completely useless to use the official solution, only give the last one a title, poor Virgo.

Added: Slow solution for pip install xxx when installing modules with Python

Recently, when using Python, various modules need to be installed, and pip is a powerful module installation tool. However, due to the fact that foreign official pypi is often blocked, it is unavailable, so we'd better replace our own pip source for 1 time, so as to solve the trouble that the library cannot be installed due to the wall.

Recently, the pip source in Tsinghua University is used more and more conveniently, which is the mirror image of pypi in official website and synchronized every 5 minutes. The address is https://pypi.tuna.tsinghua.edu.cn/simple

Temporary use method

For example, if we need to install the selenium library, we can use this installation command


pip install -i https://pypi.tuna.tsinghua.edu.cn/simple selenium 

In this way, the selenium library can be installed quickly from the mirror image of Tsinghua University.


Related articles: