场景描述:

原先pip安装完成之后,一直没有更新版本,原pip版本为8.1.1,今天安装python 包pysftp的时候,提示需要升级pip到(pip 10.0.1);

于是乎,直接手到擒来,终端命令行执行:

$ sudo pip install --upgrade pip

升级完成之后,查看版本pip --version 显示:pip 10.0.1

之后安装sudo pip install pysftp

提示:

ImportError: cannot import name ‘main‘

啥问题呀,百度?!!!

https://www.cnblogs.com/white-the-Alan/p/8900554.html

改完之后没有效果!啥子原因!囧,我特发!

原因分析:

1. 提示报错为:/user/bin/pip第九行有问题

2. which pip

/home/odoo/.local/bin/pip

搜嘎,原来更新升级之后的pip安装路径变了,没有更新/user/bin下的配置,导致我们运行pip命令的时候,执行的还是原先就的程序。我们知道/user/bin目录下的程序,基本为程序包安装时候创建的软链接!!!

知道问题原因后,就知道如何处理了。

解决方式:

两种,第一种删除旧的/user/bin下的pip软链接,重新设置。

方式二,直接卸载原有pip重新安装,指定软链接为新的路径。

这里采用的第二种,重装前先卸载ubuntu的pip包
sudo apt-get remove python-pip

重新安装:sudo apt-get install python-pip python-dev build-essential

odoo@test:/usr/bin$ sudo apt-get install python-pip python-dev build-essential
Reading package lists... Done
Building dependency tree
Reading state information... Done
build-essential is already the newest version (.1ubuntu2).
python-dev is already the newest version (2.7.-~16.04).
python-dev set to manually installed.
The following packages were automatically installed and are no longer required:
linux-headers-4.13.- linux-headers-4.13.--generic
linux-headers-4.13.- linux-headers-4.13.--generic
linux-image-4.13.--generic linux-image-4.13.--generic
linux-image-extra-4.13.--generic linux-image-extra-4.13.--generic
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
python-pip
upgraded, newly installed, to remove and not upgraded.
Need to get kB of archives.
After this operation, kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get: http://cn.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 python-pip all 8.1.1-2ubuntu0.4 [144 kB]
Fetched kB in 1s (94.4 kB/s)
Selecting previously unselected package python-pip.
(Reading database ... files and directories currently installed.)
Preparing to unpack .../python-pip_8.1.1-2ubuntu0.4_all.deb ...
Unpacking python-pip (8.1.-2ubuntu0.) ...
Processing triggers for man-db (2.7.-) ...
Setting up python-pip (8.1.-2ubuntu0.) ... odoo@test:/usr/bin$
odoo@test:/usr/bin$ pip --version
pip 10.0. from /home/odoo/.local/lib/python2./site-packages/pip (python 2.7)

创建软链接:

sudo ln -s /usr/local/bin/pip /usr/bin/pip
pip --version
pip 10.0. from /usr/local/lib/python2./dist-packages/pip-10.0.-py2..egg/pip (python 2.7)

安装pysftp 这里切换在root用户下安装了,普通用户的话需要加sudo pip install pysftp

root@odoo-test:/usr/local/bin# pip install pysftp
Collecting pysftp
Downloading https://files.pythonhosted.org/packages/36/60/45f30390a38b1f92e0a8cf4de178cd7c2bc3f874c85430e40ccf99df8fe7/pysftp-0.2.9.tar.gz
Collecting paramiko>=1.17 (from pysftp)
Downloading https://files.pythonhosted.org/packages/3e/db/cb7b6656e0e7387637ce850689084dc0b94b44df31cc52e5fc5c2c4fd2c1/paramiko-2.4.1-py2.py3-none-any.whl (194kB)
% |████████████████████████████████| 194kB .8kB/s
Requirement already satisfied: pyasn1>=0.1. in /usr/lib/python2./dist-packages (from paramiko>=1.17->pysftp) (0.1.)
Collecting bcrypt>=3.1. (from paramiko>=1.17->pysftp)
Downloading https://files.pythonhosted.org/packages/2e/5a/2abeae20ce294fe6bf63da0e0b5a885c788e1360bbd124edcc0429678a59/bcrypt-3.1.4-cp27-cp27mu-manylinux1_x86_64.whl (57kB)
% |████████████████████████████████| 61kB .0kB/s
Collecting cryptography>=1.5 (from paramiko>=1.17->pysftp)
Downloading https://files.pythonhosted.org/packages/dd/c2/3a5bfefb25690725824ade71e6b65449f0a9f4b29702cce10560f786ebf6/cryptography-2.2.2-cp27-cp27mu-manylinux1_x86_64.whl (2.2MB)
% |████████████████████████████████| .2MB 22kB/s
Collecting pynacl>=1.0. (from paramiko>=1.17->pysftp)
Downloading https://files.pythonhosted.org/packages/80/3d/d709b9fbd69e21dd3a4d34eb690c5484094699e03b7447bc7eb173cfd7b6/PyNaCl-1.2.1-cp27-cp27mu-manylinux1_x86_64.whl (696kB)
% |████████████████████████████████| 706kB .5kB/s
Requirement already satisfied: six>=1.4. in /usr/lib/python2./dist-packages (from bcrypt>=3.1.->paramiko>=1.17->pysftp) (1.10.)
Collecting cffi>=1.1 (from bcrypt>=3.1.->paramiko>=1.17->pysftp)
Downloading https://files.pythonhosted.org/packages/14/dd/3e7a1e1280e7d767bd3fa15791759c91ec19058ebe31217fe66f3e9a8c49/cffi-1.11.5-cp27-cp27mu-manylinux1_x86_64.whl (407kB)
% |████████████████████████████████| 409kB .7kB/s
Requirement already satisfied: enum34; python_version < "" in /usr/lib/python2./dist-packages (from cryptography>=1.5->paramiko>=1.17->pysftp) (1.1.)
Collecting asn1crypto>=0.21. (from cryptography>=1.5->paramiko>=1.17->pysftp)
Downloading https://files.pythonhosted.org/packages/ea/cd/35485615f45f30a510576f1a56d1e0a7ad7bd8ab5ed7cdc600ef7cd06222/asn1crypto-0.24.0-py2.py3-none-any.whl (101kB)
% |████████████████████████████████| 102kB .0kB/s
Collecting idna>=2.1 (from cryptography>=1.5->paramiko>=1.17->pysftp)
Downloading https://files.pythonhosted.org/packages/27/cc/6dd9a3869f15c2edfab863b992838277279ce92663d334df9ecf5106f5c6/idna-2.6-py2.py3-none-any.whl (56kB)
% |████████████████████████████████| 61kB .9kB/s
Requirement already satisfied: ipaddress; python_version < "" in /usr/lib/python2./dist-packages (from cryptography>=1.5->paramiko>=1.17->pysftp) (1.0.)
Collecting pycparser (from cffi>=1.1->bcrypt>=3.1.->paramiko>=1.17->pysftp)
Downloading https://files.pythonhosted.org/packages/8c/2d/aad7f16146f4197a11f8e91fb81df177adcc2073d36a17b1491fd09df6ed/pycparser-2.18.tar.gz (245kB)
% |████████████████████████████████| 256kB .4kB/s
Building wheels for collected packages: pysftp, pycparser
Running setup.py bdist_wheel for pysftp ... done
Stored in directory: /root/.cache/pip/wheels/d4///181ea4f6c795b40c4f1d2022ba2ed15cf811d22975eb2e5968
Running setup.py bdist_wheel for pycparser ... done
Stored in directory: /root/.cache/pip/wheels/c0/a1//5ba234bd77ea5a290cbf6d675259ec52293193467a12ef1f46
Successfully built pysftp pycparser
Installing collected packages: pycparser, cffi, bcrypt, asn1crypto, idna, cryptography, pynacl, paramiko, pysftp
Found existing installation: idna 2.0
Uninstalling idna-2.0:
Successfully uninstalled idna-2.0
Found existing installation: cryptography 1.2.
Uninstalling cryptography-1.2.:
Successfully uninstalled cryptography-1.2.
Successfully installed asn1crypto-0.24. bcrypt-3.1. cffi-1.11. cryptography-2.2. idna-2.6 paramiko-2.4. pycparser-2.18 pynacl-1.2. pysftp-0.2.

OK !

ubuntu升级pip后, ImportError: cannot import name ‘main‘的更多相关文章

  1. 更新pip10后 ImportError: cannot import name ‘main'(转)

    解决:找到报错文件,也就是那个pip,然后cd进目录 vi 编辑pip,将里面的内容改为如下所示: # -*- coding: utf-8 -*- import re import sys from ...

  2. 转pip更新后ImportError: cannot import name ‘main'

    更新pip后,报出:ImportError: cannot import name ‘main' 根据https://www.cnblogs.com/dylan9/p/8981155.html的教程进 ...

  3. pip install ImportError: cannot import name main

    在Ubuntu上用pip install装ansible时报错 root@user:~# pip install --no-cache-dir ansible -i http://mirrors.al ...

  4. pip 解决 ImportError: cannot import name 'main'

    当 pip 更新至最新版的时候,不管是执行 pip list 还说 pip install packageName 安装包,都会抛出一个异常 Traceback (most recent call l ...

  5. 更新pip10后 ImportError: cannot import name ‘main'

    百度了几个回答都没有解决问题,有些回答明显是直接复制过来的一点价值都没有,然后google一下立马解决.很多时候不能怪搜索引擎,问题出在一些国内网友对知识的不负责任 解决:找到报错文件,也就是那个pi ...

  6. 升级pip后出现 ImportError: cannot import name main

    原文链接   https://blog.csdn.net/accumulate_zhang/article/details/80269313 在Ubuntu中,升级了pip,再次使用pip 安装相关的 ...

  7. 升级pip后,出现ImportError:cannot import name main

    升级pip后,出现ImportError错误,如下图: 解决方法: sudo gedit /usr/bin/pip 进去后修改为 from pip import __main__ if __name_ ...

  8. ubuntu 下更新pip后发生 ImportError: cannot import name 'main'的问题解决

    今天刚使用ubuntu 由于安装的是pip 8的版本,我感觉pip版本有些低就随手将将pip更新了,刚新到pip 10版本的,没想到刚更新完就报错了, 发生 ImportError: cannot i ...

  9. 升级pip3后出现importerror:cannot import name main

    在ubuntu中,升级了pip3,再次使用pip3安装相关的python包的时候就出现以下错误 ImportError: cannot import name main 解决:pip3文件在/usr/ ...

随机推荐

  1. pyinstaller基本操作

    pyinstaller 打包错误http://www.fmwei.com/linux/pyinstaller-lib-error.html 只需要复制python安装目录下的动态库到系统地动态库目录即 ...

  2. boost-使用property_tree来解析xml、json

    property_tree是一个保存了多个属性值的树形数据结构,可以用来解析xml.json.ini.info文件.要使用property_tree和xml解析组件的话需要包含"boost/ ...

  3. Eclipse的maven项目一直无故报错

    maven项目里面没报错,就是项目名称上有红色的叉叉,看着很不舒服: install都成功,但还是有红叉,刷新也没有用,最后搞了好一会才好: 操作步骤: 1.先把项目clean下: 选中要清理的项目, ...

  4. 用IrisSkin2.dll美化你的WinForm

    From:http://hi.baidu.com/tr0j4n 在WinForm中,可以方便地给自己的程序添加皮肤,做出各种绚丽的效果,而只需要很简单的几句代码即可搞定,下面来领略下. 前期准备:1. ...

  5. (转)memcached注意事项

    转自:http://www.kaifajie.cn/kaiyuan_qita/8656.html 1.   key值最大长度? memcached的key的最大长度是250个字符. 注意250是mem ...

  6. 第75讲:模式匹配下的For循环

    今天学习了模式匹配下的for循环内容.让我们从代码实战角度出发. for(i<-List(1,2,3,4,5)) println(i)//实际上调用的是foreach        for(in ...

  7. 转载:Java项目读取配置文件时,FileNotFoundException 系统找不到指定的文件,System.getProperty("user.dir")的理解

    唉,读取个文件,也就是在项目里面去获得配置文件的目录,然后,变成文件,有事没事,总是出个 FileNotFoundException  系统找不到指定的文件,气死人啦. 还有就是:System.get ...

  8. Hadoop读写流程

    写流程 读流程 HDFS写数据流程 HDFS读数据流程 网络拓扑-节点距离计算 节点距离:两个节点到达最近的共同祖先的距离总和

  9. es快捷键

    ctrl+b ,从xml中的Design定位到代码中 ctrl+shift+t查找这个类,下面会显示类的路径,包括jar名 shift + ctrl + / :注释,如果选中多行的话,则会把选中区域注 ...

  10. cxgrid显示海量数据

    cxgrid显示海量数据 在默认情况下,cxgrid显示几万条以上的数据会很慢.怎么办? 交下面的属性设为TRUE以后,速度飞快. 但速度是快了,自动计算列的合计值这些功能却失效了,正所谓有得必有失!