Issues with PIP installation when Python2 and 3 coexist

Source: Internet
Author: User

With Python2 and Python3 Multiple versions installed, we use PIP to install modules that are prone to problems:

[[email protected] ~]# python-m pip install Psutil

Collecting Psutil

Downloading psutil-5.4.1.tar.gz (408kB)

Installed/usr/local/python3/lib/python3.6/site-packages/psutil-5.4.0-py3.6-linux-x86_64.egg

Processing dependencies for psutil==5.4.0

Finished processing dependencies for psutil==5.4.0

[[email protected] psutil-5.4.0]# python

Python 3.6.3 (Default, Nov 9 2017, 00:02:58)

[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on Linux

Type "Help", "copyright", "credits" or "license" for more information.

>>> Import Psutil

Traceback (most recent):

File "<stdin>", line 1, in <module>

File "/root/psutil-5.4.0/psutil/__init__.py", line-in <module>

From. Import _pslinux as _psplatform

File "/root/psutil-5.4.0/psutil/_pslinux.py", line +, in <module>

From. Import _psutil_linux as Cext

Importerror:cannot import name ' _psutil_linux '

This error, not without the Psutil module reported the wrong, but because my system contains python2 and Python3, so when using PIP installation, will be installed in 2, resulting in this error

When we installed 2 and 3, when using PIP to install the module, we need to declare before the PIP is 2 or 3

[[email protected] ~]# python-m pip install psutil# my system has python2.7 and Python3.6,python is version 3.6.

Collecting Psutil

Downloading psutil-5.4.1.tar.gz (408kB)

.....................

97% |███████████████████████████████▎| 399kB 738kb/s eta 0:00 100% |████████████████████████████████| 409kB 539kb/s

Installing collected Packages:psutil

Running setup.py Install for psutil ... done

Successfully installed psutil-5.4.1

[[email protected] ~]# python

Python 3.6.3 (Default, Nov 9 2017, 00:02:58)

[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on Linux

Type "Help", "copyright", "credits" or "license" for more information.

>>> Import Psutil

>>>

I used python in front of Pip to declare that I am currently using 3 instead of python2.7, so the installation is normal.


PS: Personal opinion, if there is a wrong place, please correct me.

This article is from the "All-up" blog, be sure to keep this source http://zhenghong.blog.51cto.com/1676992/1980181

Issues with PIP installation when Python2 and 3 coexist

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.