centos7 pip3 安装python模块包报错解决

centos7 pip3 安装python模块包报错(bash: /usr/local/bin/pip3: /usr/local/bin/python3.6: 坏的解释器: 没有那个文件或目录)

[root@localhost Python]# pip3 install wget
bash: /usr/local/bin/pip3: /usr/local/bin/python3.6: 坏的解释器: 没有那个文件或目录

解决:

一、先查看这( /usr/local/bin/pip3: /usr/local/bin/python3.6)两个文件是否在,然后再看/usr/local/bin/pip3指向python3路径是否正确。

[root@localhost Python]# ls /usr/local/bin/pip3 -l
-rwxr-xr-x. 1 root root 229 5月  12 01:19 /usr/local/bin/pip3
[root@localhost Python]# ls /usr/local/bin/python*
ls: 无法访问/usr/local/bin/python*: 没有那个文件或目录
[root@localhost Python]# ls /usr/local/bin/python* -l
ls: 无法访问/usr/local/bin/python*: 没有那个文件或目录
[root@localhost Python]#ls /usr/local/bin/
pip  pip3  pip3.6
[root@localhost Python]# vi /usr/local/bin/pip3
[root@localhost Python]# which python3
/usr/bin/python3
[root@localhost Python]# vi /usr/local/bin/pip3

经查看没有 /usr/local/bin/python3.6这个文件,然后系统识别python3路径在哪里,最后在看 /usr/local/bin/pip3里面的python路径是否正常,如不正常修改回来。下面已经修改保存centos7 pip3 安装python模块包报错解决_第1张图片

 二.重新安装

[root@localhost Python]# pip3 install wget
Looking in indexes: http://pypi.douban.com/simple/
Collecting wget
  Downloading http://pypi.doubanio.com/packages/47/6a/62e288da7bcda82b935ff0c6cfe542970f04e29c756b0e147251b2fb251f/wget-3.2.zip (10 kB)
  Preparing metadata (setup.py) ... done
Using legacy 'setup.py install' for wget, since package 'wheel' is not installed.
Installing collected packages: wget
    Running setup.py install for wget ... done
Successfully installed wget-3.2
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

结果还是报错如报错信息

(WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv)NG:以“root”用户运行pip可能会导致权限中断,以及与系统包管理器的行为冲突。建议使用虚拟环境:https://pip.pypa.io/warnings/venv

提示建议创建虚拟环境:

解决方案:

先了解关于虚拟目录知识:

建立一个虚拟目录

注:(虚拟目录的概念

文件很多,主目录的空间可能会不足,因此需要将上述文件存放在其他分区或其他计算机上,而用户访问时,上述文件夹在逻辑上归属网站之下,这种归属网站之下的目录称为虚拟目录。可以利用虚拟目录将一个网站的文件分散存储在同一台计算机的不同路径或不同计算机中,但这些文件在逻辑上仍归属同一个站点,并且都为Web站点的内容。)

优点:

将数据分散保存到不同的磁盘或计算机上,便于分别开发与维护。

当数据移动到其他物理位置时,不会影响到Web站点的逻辑结构。

第一:

创建虚拟环境

python3 -m venv tutorial-env

会出现以下两种情况

1.正常不显示回显,直接激活虚拟环境

[root@localhost Python]# python3 -m venv tutorial-env
[root@localhost Python]# source tutorial-env/bin/activate


接着重新安装python模块包,可以安装提示要更新pip可以直接更新就文问题了。

[root@localhost Python]# python -m pip install novas
Collecting novas
  Downloading http://pypi.doubanio.com/packages/42/95/a05bc35cb119925e10f9faa8a2bd17020b0a585744a38921a709acdd9a14/novas-3.1.1.5.tar.gz (135kB)
    100% |████████████████████████████████| 143kB 4.3MB/s 
Installing collected packages: novas
  Running setup.py install for novas ... done
Successfully installed novas-3.1.1.5
You are using pip version 9.0.3, however version 22.2.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
(tutorial-env) [root@localhost Python]# pip install --upgrade pip

如果出现其他异常可参考该文章:

 Linux pip错误分析 (Running pip as the ‘root‘ user can result in broken permissions and conflict)_干掉芹菜的博客-CSDN博客

你可能感兴趣的:(python3,python,pip,numpy)