zoukankan      html  css  js  c++  java
  • Ubuntu 常见问题以及环境配置

    1. Ubuntu时间与Windows的时间总是不一样
      其实仔细看我们可以发现两个系统的时间总是相差8个小时,原因在于:Windows把系统硬件时间当做本地时间,即操作系统中显示的时间跟BIOS中显示的时间是一样的;而Linux/Unix/Mac把硬件时间当做UTC(Universal Tine Coordinated,协调世界时),操作系统显示的时间是硬件时间经过换算得来的,比如说,北京时间是GMT+8(Greenwich Mean Time,格林尼治时间),所以系统中显示的时间是硬件时间加8.
    sudo apt-get install ntpdate  //先在Ubuntu上更新时间,确保时间无误
    sudo ntpdate time.windows.com
    sudo hwclock --localtime --systohc  //将时间更新到硬件上
    
    1. Python3的安装
      因为Ubuntu自带Python2,而Python3与Python2又传说有较大区别,所以作为初学者还是先学Python3,后面需要再去看Python2
    sudo apt-get install python3 //此时会进入Python3的安装,
    python --version //发现此时还是Python2
    //因为Ubuntu的很多底层都是采用的Python2,Python2和Python3是互不兼容的,
    ///所以此时不能卸载Python2,需要将默认Python指向Python3(其默认安装目录:/usr/local/lib)
    cd /usr/bin   //进入python link目录
    sudo rm python  //删除Python link文件
    sudo ln -s /usr/bin/python3.5 /usr/bin/python  //新建链接文件,并指向咱们新装的Python3.5
    

    2.1 内置Python2.7再装Python3注意+Ubuntu安装软件时出现处理软件包python-setuptools出错

    hello_world@LG:~$ sudo apt-get install google-chrome-stable 
    正在读取软件包列表... 完成
    正在分析软件包的依赖关系树       
    正在读取状态信息... 完成       
    google-chrome-stable 已经是最新版 (63.0.3239.108-1)。
    升级了 0 个软件包,新安装了 0 个软件包,要卸载 0 个软件包,有 358 个软件包未被升级。
    有 6 个软件包没有被完全安装或卸载。
    解压缩后会消耗 0 B 的额外空间。
    N: 忽略‘google-chrome.list.1’(于目录‘/etc/apt/sources.list.d/’),鉴于它的文件扩展名无效
    您希望继续执行吗? [Y/n] Y
    正在设置 python-wheel (0.29.0-1) ...
    Traceback (most recent call last):
      File "/usr/bin/pycompile", line 35, in <module>
        from debpython.version import SUPPORTED, debsorted, vrepr, 
      File "/usr/share/python/debpython/version.py", line 24, in <module>
        from ConfigParser import SafeConfigParser
    ImportError: No module named 'ConfigParser'
    dpkg: 处理软件包 python-wheel (--configure)时出错:
     子进程 已安装 post-installation 脚本 返回错误状态 1
    正在设置 python-pkg-resources (26.1.1-1) ...
    Traceback (most recent call last):
      File "/usr/bin/pycompile", line 35, in <module>
        from debpython.version import SUPPORTED, debsorted, vrepr, 
      File "/usr/share/python/debpython/version.py", line 24, in <module>
        from ConfigParser import SafeConfigParser
    ImportError: No module named 'ConfigParser'
    dpkg: 处理软件包 python-pkg-resources (--configure)时出错:
     子进程 已安装 post-installation 脚本 返回错误状态 1
    正在设置 python-m2crypto (0.24.0-1) ...
    Traceback (most recent call last):
      File "/usr/bin/pycompile", line 35, in <module>
        from debpython.version import SUPPORTED, debsorted, vrepr, 
      File "/usr/share/python/debpython/version.py", line 24, in <module>
        from ConfigParser import SafeConfigParser
    ImportError: No module named 'ConfigParser'
    dpkg: 处理软件包 python-m2crypto (--configure)时出错:
     子进程 已安装 post-installation 脚本 返回错误状态 1
    dpkg: 依赖关系问题使得 shadowsocks 的配置工作不能继续:
     shadowsocks 依赖于 python-pkg-resources;然而:
      软件包 python-pkg-resources 尚未配置。
     shadowsocks 依赖于 python-m2crypto;然而:
      软件包 python-m2crypto 尚未配置。
    
    dpkg: 处理软件包 shadowsocks (--configure)时出错:
     依赖关系问题 - 仍未被配置
    正在设置 python-pip (8.1.2-2ubuntu0.1) ...
    由于已经达到 MaxReports 限制,没有写入 apport 报告。
                                                        Traceback (most recent call last):
      File "/usr/bin/pycompile", line 35, in <module>
        from debpython.version import SUPPORTED, debsorted, vrepr, 
      File "/usr/share/python/debpython/version.py", line 24, in <module>
        from ConfigParser import SafeConfigParser
    ImportError: No module named 'ConfigParser'
    dpkg: 处理软件包 python-pip (--configure)时出错:
     子进程 已安装 post-installation 脚本 返回错误状态 1
    dpkg: 依赖关系问题使得 python-setuptools 的配置工作不能继续:
     python-setuptools 依赖于 python-pkg-resources (= 26.1.1-1);然而:
      软件包 python-pkg-resources 尚未配置。
    
    由于已经达到 MaxReports 限制,没有写入 apport 报告。
                                                        由于已经达到 MaxReports 限制,没有写入 apport 报告。
                            dpkg: 处理软件包 python-setuptools (--configure)时出错:
     依赖关系问题 - 仍未被配置
    在处理时有错误发生:
     python-wheel
     python-pkg-resources
     python-m2crypto
     shadowsocks
     python-pip
     python-setuptools
    E: Sub-process /usr/bin/dpkg returned an error code (1)
    
    • 原因如下:我们在内置Python2的情况下安装Python3时,只是把原来Python2的Python link文件利用ls转移到Python3,但是其配置目录没有修改。方法如下:
    sudo apt-get clean
    sudo apt-get update
    sudo apt-get install --reinstall python-minimal python-lockfile
    

    2.2 内置Python2.7再装Python3注意 + PIP版本问题

    • 问题重现:
    You are using pip version 8.1.2, however version 9.0.1 is available.
    You should consider upgrading via the 'pip install --upgrade pip' command.
    
    • 可以发现:
    hello_world@LG:~$ sudo pip3 --version
    pip 9.0.1 from /home/hello_world/.local/lib/python3.5/site-packages (python 3.5)
    hello_world@LG:~$ sudo -H pip3 --version
    pip 8.1.2 from /usr/lib/python3/dist-packages (python 3.5)
    
    • 解决方案:
    sudo -H pip3 install --upgrade pip
    
    hello_world@LG:~$ sudo -H pip3 install --upgrade pip
    Collecting pip
      Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB)
        100% |████████████████████████████████| 1.3MB 762kB/s 
    Installing collected packages: pip
      Found existing installation: pip 8.1.2
        Not uninstalling pip at /usr/lib/python3/dist-packages, outside environment /usr
    Successfully installed pip-9.0.1
    hello_world@LG:~$ sudo -H pip3 --version
    pip 9.0.1 from /usr/local/lib/python3.5/dist-packages (python 3.5)
    hello_world@LG:~$ sudo pip3 --version
    pip 9.0.1 from /home/hello_world/.local/lib/python3.5/site-packages (python 3.5)
    hello_world@LG:~$
    
  • 相关阅读:
    夺命雷公狗---PDO NO:9 使用PDO准备语句并执行语句3
    夺命雷公狗---PDO NO:9 使用PDO准备语句并执行语句2
    [LeetCode] Lowest Common Ancestor of a Binary Search Tree
    二叉树
    LeetCode Palindrome LinkList
    LeetCode Same Tree
    LeetCode Merge Sorted List
    LeetCode Remove Duplicated from Sorted List
    LeetCode Climbing Stairs
    LeetCode Count And Say
  • 原文地址:https://www.cnblogs.com/qiulinzhang/p/9513868.html
Copyright © 2011-2022 走看看