• python错误记录


    raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e) django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb'

    没有在__init__.py文件中导入pymysql

    __init__.py

    import pymysql
    pymysql.install_as_MySQLdb()

    goods.GoodsImage.image: (fields.E210) Cannot use ImageField because Pillow is not installed.
    HINT: Get Pillow at https://pypi.python.org/pypi/Pillow or run command "pip install Pillow".

    没有安装pillow

    pip install pillow

    缩进错误:

    IndentationError: unexpected indent

    pip安装超时:

    1.添加超时时间

    pip install 要安装的包名 --timeout 100

     2.修改pip配置文件

    创建pip.conf文件
    mkdir ~/.pip
    cd ~/.pip
    在.pip目录下创建一个pip.conf文件
    
    touch pip.conf
    文件就创建好了(当然如果你已经有这个文件了这步可以跳过).
    
    2. 编辑pip.conf文件
    sudo gedit ~/.pip/pip.conf
    打开pip.conf文件窗口,将以下内容复制到文件中:

      [global]

      timeout = 6000 # 修改pip等待时间

    
    [global] 
    index-url = http://pypi.douban.com/simple   # 换源
    [install] 
    trusted-host=pypi.douban.com

     虚拟环境创建失败

    OSError: Command /home/kevin2/.virtua...ramid_p2/bin/python2 - setuptools pip wheel failed with error code 2

    1.升级pip

    2.换源

    #在.pip目录创建并编辑pip.conf
    #pip安装需要使用的https加密,所以在此需要添加trusted-host 
    [global]
    trusted-host = mirrors.ustc.edu.cn
    index-url = https://mirrors.ustc.edu.cn/pypi/web/simple

    空文件发送:

    new_client_socket.send(send_content)
    TypeError: a bytes-like object is required, not 'NoneType'

    Traceback (most recent call last):
      File "/usr/local/bin/pip3", line 7, in <module>
        from pip import main
      File "/usr/local/lib/python3.5/dist-packages/pip/__init__.py", line 43, in <module>
        from pip.utils import get_installed_distributions, get_prog
      File "/usr/local/lib/python3.5/dist-packages/pip/utils/__init__.py", line 27, in <module>
        from pip._vendor import pkg_resources
      File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 3018, in <module>
        @_call_aside
      File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 3004, in _call_aside
        f(*args, **kwargs)
      File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 3046, in _initialize_master_working_set
        dist.activate(replace=False)
      File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 2578, in activate
        declare_namespace(pkg)
      File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 2152, in declare_namespace
        _handle_ns(packageName, path_item)
      File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 2092, in _handle_ns
        _rebuild_mod_path(path, packageName, module)
      File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 2121, in _rebuild_mod_path
        orig_path.sort(key=position_in_sys_path)
    AttributeError: '_NamespacePath' object has no attribute 'sort'

    pip3 install --upgrade pip setuptools不行的时候

    修改了一下 "sudo vim /usr/local/lib/python3.5/dist-packages/pip/_vendor/pkg_resources/__init__.py"

    #orig_path.sort(key=position_in_sys_path)
    #module.__path__[:] = [_normalize_cached(p) for p in orig_path]
    orig_path_t = list(orig_path)
    orig_path_t.sort(key=position_in_sys_path)
    module.__path__[:] = [_normalize_cached(p) for p in orig_path_t]
    Traceback (most recent call last):
      File "/usr/local/bin/pip3", line 7in <module>
        from pip import main
      File "/usr/local/lib/python3.5/dist-packages/pip/__init__.py", line 43in <module>
        from pip.utils import get_installed_distributions, get_prog
      File "/usr/local/lib/python3.5/dist-packages/pip/utils/__init__.py", line 27in <module>
        from pip._vendor import pkg_resources
      File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 3018in <module>
        @_call_aside
      File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 3004in _call_aside
        f(*args, **kwargs)
      File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 3046in _initialize_master_working_set
        dist.activate(replace=False)
      File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 2578in activate
        declare_namespace(pkg)
      File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 2152in declare_namespace
        _handle_ns(packageName, path_item)
      File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 2092in _handle_ns
        _rebuild_mod_path(path, packageName, module)
      File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 2121in _rebuild_mod_path
        orig_path.sort(key=position_in_sys_path)
    AttributeError: '_NamespacePath' object has no attribute 'sort'

     然后我试了很多种方法,而且还根据许多其他答案pip3 install --upgrade pip setuptools等等都不行,最终还是在外文的一个讨论区找到一个,修改了一下,觉得还可以:

    具体来说就是编辑文件#2121~2122 : "sudo vim /usr/local/lib/python3.5/dist-packages/pip/_vendor/pkg_resources/__init__.py"

    1
    2
    3
    4
    5
    #orig_path.sort(key=position_in_sys_path)
    #module.__path__[:] = [_normalize_cached(p) for p in orig_path]
    orig_path_t = list(orig_path)
    orig_path_t.sort(key=position_in_sys_path)
    module.__path__[:] = [_normalize_cached(p) for in orig_path_t]
  • 相关阅读:
    jenkins+ant+jmeter实现自动化集成(详解)
    Android ADB命令 adb devices 出现error:protocol fault (no status)
    使用jmeter做接口测试
    估计新版本所需要的案例数量
    《将博客搬至CSDN》
    HDFS NN refreshNodes操作的可用性和效率的改进
    visudo: /etc/sudoers 忙,请稍后重试解决办法
    Java try与finally对返回值的影响
    Java中基本类型和包装类比较的问题
    Java中ArrayList去重方法
  • 原文地址:https://www.cnblogs.com/yifengs/p/11577810.html
Copyright © 2020-2023  润新知