Tag Archives: pip

[Solved] python Install pip Error: zipimport.ZipImportError: can’t decompress data; zlib not available



1. Install dependent packages

yum -y install zlib*

2. Recompile Python

#The catalog is based on the production environment itself
[[email protected] software]# cd Python/
[[email protected] Python]# ./configure --prefix=/usr/local/python3

#Compile and install
[[email protected] Python]# make && make install

# re-install
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py

Python — the copied virtual environment PIP command failed to run. Fatal error in launcher: unable to create process using

Original text: https://blog.csdn.net/weixin_ 39278265/article/details/82938270

You need to modify the directory referenced in the pip.exe file in the scripts directory of the virtual environment.

Referring to the original text, I used Notepad + + to open pip.exe, and then searched according to the python path information prompted,

After finding it, replace it with the path of python.exe in the current virtual environment and save it.

Python Via get-pip.py Install pip Error: zipimport.ZipImportError: can‘t decompress data; zlib not availabl

How to Solve error: zipimport.ZipImportError: can‘t decompress data; zlib not availablwget https://bootstrap.pypa.io/pip/2.7/get-pip.py  # python2.7
wget https://bootstrap.pypa.io/get-pip.py  # python3

[[email protected] ~]$ https://bootstrap.pypa.io/get-pip.py
[[email protected] ~]$ sudo python get-pip.py

The error message “zipimport.ZipImportError: can’t decompress data; zlib not available”
It seems that the zlib library is missing and needs to be installed before execution.
Problem solved

1 [[email protected] ~]$ sudo yum install zlib

After the installation was completed, we found that it still reported an error, and a Google search revealed that we needed to install zlib-dev
So we install the zlib library again

1 [[email protected] ~]$ sudo yum install zlib*

This time the installation should be OK, but the result is disappointing, it still gives the same error.
But we have already installed the zlib library, why does it still give us an error?

We need to recompile and install python
Before recompiling, we need to modify the Modules/Setup.dist file in the installation source file to change the

1 #zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz

The comment on this line is removed and becomes

1 zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz

Then compile and install it again (execute the following command in Python’s installation source directory)

1 [[email protected] ~]$ make && make install

Reinstallation completed

1 [[email protected] ~]$ sudo python get-pip.py

Install pip successfully!

[PIP command error] after upgrading the PIP in Ubuntu 16.04, execute the PIP command to report an error sys.stderr.write (F “error: {exc}”)

Get the repair file get-pip.py

    Access get repair file

    Find the download link of the corresponding version file, such as Python 3.5, https://bootstrap.pypa.io/pip/3.5/get-pip.py

    Download using WGet, WGet https://bootstrap.pypa.io/pip/3.5/get-pip.py

    Execute the file using the corresponding version of python, Python 3.5 get pip. Py

How to Solve Error in installing MySQL Python in Pip

Error 1: EnvironmentError: mysql_config not found

Solution: yum install mysql-devel

Error 2: Python.h No such file or directory

For more errors see the following lines.

_mysql.c:29:20: fatal error: Python.h: No such file or directory
#include “Python.h”
compilation terminated.
error: command ‘gcc’ failed with exit status 1

Solution: yum install python-devel.x86_64

In fact, these two errors are one and the same, both are not installed python-devel, only error 2 is 64-bit


Handling method of PIP error in pycharm installation

When using pycharm these days, I found that I reported it when installing the software  module ‘pip’ has no attribute ‘main’  , later, the online methods and analysis error prompts were integrated because there was a packaging in the pycharm installation directory_There are two pieces of code in the tool.py file. There are some problems with the configuration and some changes need to be made

The original code is as follows:

 1 def do_install(pkgs):
 3     try:
 4         import pip
 5     except ImportError:
 6         error_no_pip()
 7     return pip.main(['install'] + pkgs)
10 def do_uninstall(pkgs):
11     try:
12         import pip      
13     except ImportError:
14         error_no_pip()
15     return pip.main(['uninstall', '-y'] + pkgs)

Modify it to the following code:

 1 def do_install(pkgs):
 3     try:
 4         #import pip
 5             try:
 6                     from pip._internal import main   
 7             except Exception:
 8                     from pip import main
 9     except ImportError:
10         error_no_pip()
11     return main(['install'] + pkgs)
14 def do_uninstall(pkgs):
15     try:
16         #import pip
17             try:
18                   from pip._internal import main
19             except Exception:
20                   from pip import main        
21     except ImportError:
22         error_no_pip()
23     return main(['uninstall', '-y'] + pkgs)

If you report an error after modification, it may be a problem of indentation. You must pay attention to the indentation of the code. Python’s indentation requirements can be called abnormal


Mac OS uses pip to install pandas prompt cannot install ‘numpy’ solution

When I was rebuilding my computer’s plotly environment, I encountered a problem, that is, when I used pip to install pandas, I always prompted:

pip uninstall numpy
Cannot uninstall 'numpy'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

Due to the limited level of English, at the beginning of the period, I thought it was due to insufficient authority, and sudo still reported an error. After translating with the help of tools, it is found that numpy cannot be unloaded for the following reasons:

This is a distutils installed project, so we cannot determine exactly which files belong to it, which would result in only a partial uninstallation.

Numpy is a standard library. It reminds me that some software in the windows system will be placed in the system folder when it is installed. As a result, the prompt can not accurately identify the files that need to be unloaded and deleted, resulting in the failure of unloading. Although it is not clear why numpy needs to be uninstalled before pandas is installed, PIP is used to install a wave first. The tips are as follows:

Requirement already satisfied: numpy in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (1.8.0rc1)

Still can’t, simply delete directly. To remind you, backup first, and then install numpy again after installation, so it’s safer

/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python$ ls | grep numpy
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python$ sudo mv numpy-1.8.0rc1-py2.7.egg-info /Users/fv/

There are also some pitfalls: looking at the foreign netizens, there are many bugs in the version of 3. + and I really want to roll back to 2.4. New computers must pay attention to the version of the relevant dependency library. Sometimes the plot prompt can’t find the module, just because the version is too low