CentOS7.x中无法直接通过pip3命令安装程序、ipython3无法正常使用。

本文主要是介绍CentOS7.x中无法直接通过pip3命令安装程序、ipython3无法正常使用。,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

一、问题现象

1、通过pip -V查看版本

[root@localhost bin]# pip -V

显示如下:

pip 20.2b1 from /usr/lib/python2.7/site-packages/pip-20.2b1-py2.7.egg/pip (python 2.7)
[root@localhost bin]# pip3 -V

显示如下:

bash: /usr/bin/pip3: /usr/bin/python3: 坏的解释器: 没有那个文件或目录

在python3的安装目录/usr/local/python3/bin下用./pip3 -V命令查看版本:

[root@localhost bin]# ./pip3 -V

显示如下:

pip 20.1.1 from /usr/local/python3/lib/python3.8/site-packages/pip (python 3.8)

无法直接通过pip3 -V查看其版本,属于软链接的问题,解决过程如下:

[root@localhost bin]# pip3 -V
bash: /usr/bin/pip3: /usr/bin/python3: 坏的解释器: 没有那个文件或目录
[root@localhost bin]# pip -V
pip 20.2b1 from /usr/lib/python2.7/site-packages/pip-20.2b1-py2.7.egg/pip (python 2.7)
[root@localhost bin]# ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3ln: 无法创建符号链接"/usr/bin/pip3": 文件已存在
[root@localhost bin]# rm /usr/bin/pip3
rm:是否删除普通文件 "/usr/bin/pip3"?y
[root@localhost bin]# ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
[root@localhost bin]# pip3 -V
pip 20.1.1 from /usr/local/python3/lib/python3.8/site-packages/pip (python 3.8)

2、通过ipython -V查看版本

[root@localhost bin]# ipython -V
3.2.1

在python3的安装目录/usr/local/python3/bin下用./ipython -V和./ipython3 -V查看,均返回如下异常:

Traceback (most recent call last):
File "./ipython3", line 5, in <module> from IPython import start_ipython ModuleNotFoundError: No module named 'IPython'

二、尝试解决

在/usr/local/python3/bin目录重新使用./pip3 install ipython安装:

[root@localhost bin]# ./pip3 install ipython
Requirement already satisfied: ipython in usr/local/python3/lib/python3.8/site-packages (6.1.0)

于是,接着尝试在/usr/local/python3/lib/python3.8/site-packages目录下,通过vi ipython-6.1.0-py3.8.egg-info修改Version: 6.1.0为Version: 6.1.111,发现再使用./pip3 install ipython安装,提示变为…(6.1.111),由此可见,ipython-6.1.0-py3.8.egg-info文件在修复该问题过程中起了阻碍作用。
通过mv命令重命名这个文件,重新执行./pip3 install ipython后,通过./ipython3命令可以进入ipython3。
重新安装ipython及验证安装过程如下:

[root@localhost bin]# ./pip3 install ipythonCollecting ipython
Using cached ipython-7.16.1-py3-none-any.whl (785 kB)
Collecting jedi>=0.10Using cached jedi-0.17.2-py2.py3-none-any.whl (1.4 MB)
Requirement already satisfied: pygments in /usr/local/python3/lib/python3.8/site-packages (from ipython) (2.6.1)
Requirement already satisfied: prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0 in /usr/local/python3/lib/python3.8/site-packages (from ipython) (3.0.5)
Collecting backcallUsing cached backcall-0.2.0-py2.py3-none-any.whl (11 kB)
Requirement already satisfied: decorator in /usr/local/python3/lib/python3.8/site-packages (from ipython) (4.4.2)
Requirement already satisfied: pexpect; sys_platform != "win32" in /usr/local/python3/lib/python3.8/site-packages (from ipython) (4.8.0)
Requirement already satisfied: setuptools>=18.5 in /usr/local/python3/lib/python3.8/site-packages (from ipython) (41.2.0)
Requirement already satisfied: pickleshare in /usr/local/python3/lib/python3.8/site-packages (from ipython) (0.7.5)
Requirement already satisfied: traitlets>=4.2 in /usr/local/python3/lib/python3.8/site-packages (from ipython) (4.3.3)
Collecting parso<0.8.0,>=0.7.0
Using cached parso-0.7.0-py2.py3-none-any.whl (100 kB)
Requirement already satisfied: wcwidth in /usr/local/python3/lib/python3.8/site-packages (from prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0->ipython) (0.2.5)
Requirement already satisfied: ptyprocess>=0.5 in /usr/local/python3/lib/python3.8/site-packages (from pexpect; sys_platform != "win32"->ipython) (0.6.0)
Requirement already satisfied: ipython-genutils in /usr/local/python3/lib/python3.8/site-packages (from traitlets>=4.2->ipython) (0.2.0)
Requirement already satisfied: six in /usr/local/python3/lib/python3.8/site-packages (from traitlets>=4.2->ipython) (1.15.0)
Installing collected packages: parso, jedi, backcall, ipython
Successfully installed backcall-0.2.0 ipython-7.16.1 jedi-0.17.2 parso-0.7.0
[root@localhost bin]# ./pip3 install ipython
Requirement already satisfied: ipython in /usr/local/python3/lib/python3.8/site-packages (7.16.1)
Requirement already satisfied: pygments in /usr/local/python3/lib/python3.8/site-packages (from ipython) (2.6.1)
Requirement already satisfied: jedi>=0.10 in /usr/local/python3/lib/python3.8/site-packages (from ipython) (0.17.2)
Requirement already satisfied: backcall in /usr/local/python3/lib/python3.8/site-packages (from ipython) (0.2.0)
Requirement already satisfied: pickleshare in /usr/local/python3/lib/python3.8/site-packages (from ipython) (0.7.5)
Requirement already satisfied: decorator in /usr/local/python3/lib/python3.8/site-packages (from ipython) (4.4.2)
Requirement already satisfied: prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0 in /usr/local/python3/lib/python3.8/site-packages (from ipython) (3.0.5)
Requirement already satisfied: traitlets>=4.2 in /usr/local/python3/lib/python3.8/site-packages (from ipython) (4.3.3)
Requirement already satisfied: setuptools>=18.5 in /usr/local/python3/lib/python3.8/site-packages (from ipython) (41.2.0)
Requirement already satisfied: pexpect; sys_platform != "win32" in /usr/local/python3/lib/python3.8/site-packages (from ipython) (4.8.0)
Requirement already satisfied: parso<0.8.0,>=0.7.0 in /usr/local/python3/lib/python3.8/site-packages (from jedi>=0.10->ipython) (0.7.0)
Requirement already satisfied: wcwidth in /usr/local/python3/lib/python3.8/site-packages (from prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0->ipython) (0.2.5)
Requirement already satisfied: six in /usr/local/python3/lib/python3.8/site-packages (from traitlets>=4.2->ipython) (1.15.0)
Requirement already satisfied: ipython-genutils in /usr/local/python3/lib/python3.8/site-packages (from traitlets>=4.2->ipython) (0.2.0)
Requirement already satisfied: ptyprocess>=0.5 in /usr/local/python3/lib/python3.8/site-packages (from pexpect; sys_platform != "win32"->ipython) (0.6.0)
[root@localhost bin]# ./ipython3
Python 3.8.3 (default, Jul 20 2020, 19:47:15) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.16.1 -- An enhanced Interactive Python. Type '?' for help.
In [1]: a = input()                                                      
2+3
In [2]: a                                                                
Out[2]: '2+3'

创建软链接(https://blog.csdn.net/xhx94/article/details/98865598),并测试ipython3:

[root@localhost bin]# ln -s /usr/local/python3/bin/ipython3 /usr/bin/ipython3
[root@localhost bin]# ipython3
Python 3.8.3 (default, Jul 20 2020, 19:47:15) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.16.1 -- An enhanced Interactive Python. Type '?' for help.In [1]: num = input('Please input a number:')                            
Please input a number:100+200In [2]: num                                                              
Out[2]: '100+200'

三、原因分析

可能的原因是:多个python版本导致安装pip时出现版本混乱,以及使用pip install ipython命令安装时,版本选择也产生混乱。

四、向大神求助

如果哪位大神知晓问题的原因,欢迎留言指教,多谢!!

这篇关于CentOS7.x中无法直接通过pip3命令安装程序、ipython3无法正常使用。的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/458089

相关文章

使用Java解析JSON数据并提取特定字段的实现步骤(以提取mailNo为例)

《使用Java解析JSON数据并提取特定字段的实现步骤(以提取mailNo为例)》在现代软件开发中,处理JSON数据是一项非常常见的任务,无论是从API接口获取数据,还是将数据存储为JSON格式,解析... 目录1. 背景介绍1.1 jsON简介1.2 实际案例2. 准备工作2.1 环境搭建2.1.1 添加

centos7基于keepalived+nginx部署k8s1.26.0高可用集群

《centos7基于keepalived+nginx部署k8s1.26.0高可用集群》Kubernetes是一个开源的容器编排平台,用于自动化地部署、扩展和管理容器化应用程序,在生产环境中,为了确保集... 目录一、初始化(所有节点都执行)二、安装containerd(所有节点都执行)三、安装docker-

如何使用celery进行异步处理和定时任务(django)

《如何使用celery进行异步处理和定时任务(django)》文章介绍了Celery的基本概念、安装方法、如何使用Celery进行异步任务处理以及如何设置定时任务,通过Celery,可以在Web应用中... 目录一、celery的作用二、安装celery三、使用celery 异步执行任务四、使用celery

使用Python绘制蛇年春节祝福艺术图

《使用Python绘制蛇年春节祝福艺术图》:本文主要介绍如何使用Python的Matplotlib库绘制一幅富有创意的“蛇年有福”艺术图,这幅图结合了数字,蛇形,花朵等装饰,需要的可以参考下... 目录1. 绘图的基本概念2. 准备工作3. 实现代码解析3.1 设置绘图画布3.2 绘制数字“2025”3.3

Jsoncpp的安装与使用方式

《Jsoncpp的安装与使用方式》JsonCpp是一个用于解析和生成JSON数据的C++库,它支持解析JSON文件或字符串到C++对象,以及将C++对象序列化回JSON格式,安装JsonCpp可以通过... 目录安装jsoncppJsoncpp的使用Value类构造函数检测保存的数据类型提取数据对json数

python使用watchdog实现文件资源监控

《python使用watchdog实现文件资源监控》watchdog支持跨平台文件资源监控,可以检测指定文件夹下文件及文件夹变动,下面我们来看看Python如何使用watchdog实现文件资源监控吧... python文件监控库watchdogs简介随着Python在各种应用领域中的广泛使用,其生态环境也

Python中构建终端应用界面利器Blessed模块的使用

《Python中构建终端应用界面利器Blessed模块的使用》Blessed库作为一个轻量级且功能强大的解决方案,开始在开发者中赢得口碑,今天,我们就一起来探索一下它是如何让终端UI开发变得轻松而高... 目录一、安装与配置:简单、快速、无障碍二、基本功能:从彩色文本到动态交互1. 显示基本内容2. 创建链

element-ui下拉输入框+resetFields无法回显的问题解决

《element-ui下拉输入框+resetFields无法回显的问题解决》本文主要介绍了在使用ElementUI的下拉输入框时,点击重置按钮后输入框无法回显数据的问题,具有一定的参考价值,感兴趣的... 目录描述原因问题重现解决方案方法一方法二总结描述第一次进入页面,不做任何操作,点击重置按钮,再进行下

springboot整合 xxl-job及使用步骤

《springboot整合xxl-job及使用步骤》XXL-JOB是一个分布式任务调度平台,用于解决分布式系统中的任务调度和管理问题,文章详细介绍了XXL-JOB的架构,包括调度中心、执行器和Web... 目录一、xxl-job是什么二、使用步骤1. 下载并运行管理端代码2. 访问管理页面,确认是否启动成功

使用Nginx来共享文件的详细教程

《使用Nginx来共享文件的详细教程》有时我们想共享电脑上的某些文件,一个比较方便的做法是,开一个HTTP服务,指向文件所在的目录,这次我们用nginx来实现这个需求,本文将通过代码示例一步步教你使用... 在本教程中,我们将向您展示如何使用开源 Web 服务器 Nginx 设置文件共享服务器步骤 0 —