自己在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__':


from pip import __main__
if __name__ == '__main__':
  • 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!

    • 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.

  • 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!

  • 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.

发表评论 说点什么