zoukankan      html  css  js  c++  java
  • solution for python can not import local module

    blog

    这次遇到的问题是sys.path的输出不包含'',导致无法import当前文件和文件夹

    When no ._pth file is found, this is how sys.path is populated on Windows:

    • An empty entry is added at the start, which corresponds to the current directory.
    • If the environment variable PYTHONPATH exists, as described in Environment variables, its entries are added next. Note that on Windows, paths in this variable must be separated by semicolons, to distinguish them from the colon used in drive identifiers (C: etc.).
    • Additional “application paths” can be added in the registry as subkeys ofSOFTWAREPythonPythonCore{version}PythonPath under both the HKEY_CURRENT_USER and HKEY_LOCAL_MACHINE hives. Subkeys which have semicolon-delimited path strings as their default value will cause each path to be added to sys.path. (Note that all known installers only use HKLM, so HKCU is typically empty.)
    • If the environment variable PYTHONHOME is set, it is assumed as “Python Home”. Otherwise, the path of the main Python executable is used to locate a “landmark file” (either Libos.py or pythonXY.zip) to deduce the “Python Home”. If a Python home is found, the relevant sub-directories added to sys.path (Libplat-win, etc) are based on that folder. Otherwise, the core Python path is constructed from the PythonPath stored in the registry.
    • If the Python Home cannot be located, no PYTHONPATH is specified in the environment, and no registry entries can be found, a default path with relative entries is used (e.g. .Lib;.plat-win, etc).

    解决方案删除._pth文件,解决这个bug的经验教训就是一定要一步一步跟踪到问题原因,论英文文档的重要性

  • 相关阅读:
    模型命名规范
    Jquery 将表单序列化为Json对象
    Failed to read auto-increment value from storage engine错误的处理方法
    css样式表中设置table的第一列的宽度是固定值
    thinkphp中I("parm")用法的注意事项
    获取凌晨00:00:00的时间
    php empty()和isset()的区别
    react续集
    react的笔记整理
    vuex
  • 原文地址:https://www.cnblogs.com/demian/p/10461701.html
Copyright © 2011-2022 走看看