ubuntu下自定义安装python3后pip的错误

  • 2018-09-17
  • 1,535
  • 8

自己在ubuntu中安装python3.6后常见错误及解决,因为 stackoverflow 上回答较多,有时也不知道看哪一个,所以我将其总结收集起来,原回答在参考中已附:

1. 问题1: No module named “apt_pkg”:

解决方案:卸载后重装 python-apt,再把apt_pkg 的 py3.5 版 复制为 py3.6。参考: stackoverflow: python-dev installation error: ImportError: No module named apt_pkg

sudo apt-get remove --purge python-apt
sudo apt-get install python-apt -f
# sudo find / -name "apt_pkg.cpython-35m-x86_64-linux-gnu.so" # locate ".so", in generally, location is "/usr/lib/python3/dist-packages/"
cd /usr/lib/python3/dist-packages/
sudo cp apt_pkg.cpython-35m-x86_64-linux-gnu.so apt_pkg.cpython-36m-x86_64-linux-gnu.so

2. 问题2: No module named “pip._internal”:

解决方案:重装 pip 即可,(参考: github/pypa/pip: ModuleNotFoundError: No module named ‘pip._internal’)

wget https://bootstrap.pypa.io/get-pip.py  --no-check-certificate
sudo python get-pip.py

3. 问题3: ImportError: cannot import name main:

更新 pip 时可能的错误。解决方案( 参考: stackoverflow: Error after upgrading pip: cannot import name ‘main’):

修改 pip 文件内容:

sudo vim /usr/bin/pip

from pip import main
if __name__ == '__main__':
    sys.exit(main())

替换为

from pip import __main__
if __name__ == '__main__':
    sys.exit(__main__._main())

版权声明: 本网站所有资源采用BY-NC-SA 4.0协议进行授权,转载应当以相同方式注明文章来自:ubuntu下自定义安装python3后pip的错误 - 一方的天地

评论

  • Horny Girls Cam回复

    Hello this is kind of of off topic but I was wanting to know if blogs use WYSIWYG
    editors or if you have to manually code with HTML. I’m starting a blog soon but have no coding expertise so
    I wanted to get advice from someone with experience.

    Any help would be enormously appreciated!

    • root回复

      Here you can ask anything, I’ll answer whatever I know.
      If you don’t have coding expertise, then I recommend you learn a little bit markdown, it is a simple lightweight markup language.
      I’m using WP Editor.md to write my blog, this editor will auto parse md to html.

  • Blonde Milf回复

    Wow, this paragraph is fastidious, my younger sister is analyzing
    these things, therefore I am going to inform her.

    • root回复

      Thanks.

  • administration services breda回复

    Hi there, I discovered your web site by the use of Google even as looking for a similar subject, your
    web site got here up, it appears to be like good. I’ve bookmarked it in my google
    bookmarks.
    Hello there, simply turned into alert to your weblog thru Google,
    and located that it’s really informative. I am going to
    watch out for brussels. I will appreciate in case you proceed this in future.
    Numerous other people will be benefited out of your writing.
    Cheers!

  • babyboomnagels回复

    Excellent goods from you, man. I have understand your stuff previous to and you’re
    just extremely wonderful. I really like what you have
    acquired here, really like what you are saying and the way in which you say
    it. You make it entertaining and you still take care of to keep it wise.
    I can’t wait to read far more from you. This is actually a wonderful
    web site.

  • hhh回复

    王大仙

发表评论

陕ICP备18010914号
知识共享许可协议
本作品由一方天地采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可,转载或引用本站文章应遵循相同协议。如果有侵犯版权的资源请尽快联系站长,本站会在24h内删除有争议的资源。 -