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 of\SOFTWARE\Python\PythonCore{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 Lib\os.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的经验教训就是一定要一步一步跟踪到问题原因,论英文文档的重要性

转载于:https://www.cnblogs.com/demian/p/10461701.html

solution for python can not import local module相关推荐

  1. python 3.8.0 编译报错 Could not import runpy module 解决方案

    环境 CentOS 7 Gcc 4.8.5 Python 3.8.0 相关报错 make build_all CFLAGS_NODIST=" -fprofile-use -fprofile- ...

  2. 让Python每次都import最新.py文件(module)的方法

    出于某种执着的原因, 我对python的import+reload机制不太满意. 想想吧: import是一条statement, 连expression都不是, 而reload是一个builtin函 ...

  3. python安装modify setup选哪-python 之禅 import this

    dongweiming的博客 前言 我这个博客一直都是一些技术分享,show code的地方,我从来没有写过个人生活或者情感杂谈,当然我也从来没有谈论过我对什么东西的喜恶. 很多人喜欢喷XX语言,喜欢 ...

  4. python不是内部或外部命令的解决方法_详解python常见报错--NO MODULE NAMED _SQLITE3解决方法...

    概述 在安装一些基于python的程序时,经常遇到"ImportError: No module named _sqlite3"问题. 下面记录下解决方法. 解决办法 1.编译sq ...

  5. python 之禅 import this

    dongweiming的博客 前言 我这个博客一直都是一些技术分享,show code的地方,我从来没有写过个人生活或者情感杂谈,当然我也从来没有谈论过我对什么东西的喜恶. 很多人喜欢喷XX语言,喜欢 ...

  6. Python: How to import other Python files

    原文地址:http://stackoverflow.com/questions/2349991/python-how-to-import-other-python-files/20749411#207 ...

  7. python import_Python中import机制

    Python语言中import的使用很简单,直接使用import module_name语句导入即可.这里我主要写一下"import"的本质. Python官方定义:Python ...

  8. python搜索路径顺序_Python module之搜索路径

    最近,好多事,新学期课又是出奇的多,于是我就好久没更新了,今天周末,我决定将最近的学习所得整理一下,POST上来. 首先是,最近一直在做有关web开发的事,所以最近几篇主要关于django框架的使用, ...

  9. python哪个关键字可以导入模块_关于python导入模块import与常见的模块详解

    0.什么是python模块?干什么的用的? Java中如果使用abs()函数,则需要需要导入Math包,同样python也是封装的,因为python提供的函数太多,所以根据函数的功能将其封装在不同的m ...

最新文章

  1. win10系统定位服务器地址,win10系统定位服务器地址
  2. shell训练营Day18
  3. Python 技术篇-用paramiko库实现linux服务器文件下载到winodws本地实例演示
  4. bgrfc entry point
  5. Nodejs 中的包、npm 、第三方模块、 package.json 以及 cnpm
  6. kotlin中既继承又实现_Kotlin程序| 解决继承中的主要冲突的示例
  7. 浅谈云计算三个层次SaaS/PaaS/IaaS
  8. swift 2.0 语法 循环
  9. 调试时碰到的错误syntax error, expect {, actual int, pos 1, json : 3
  10. 反卷积(转置卷积)的理解
  11. linux pm2 权限,pm2 部署 node的三种方法示例
  12. epcs1s是epcs1系列的么_串行FLASH配置芯片(EPCS1或EPCS4)数据手册.pdf
  13. 如何用HTML制作一个3行3列的表格,如何利用表格制作网页
  14. 区块链底层平台有哪些 区块链底层平台搭建
  15. 数据链路层的基本概念
  16. Bootstrap4表单验证(纯JavaScript方法)
  17. Oracle动态采样分析
  18. 亚马逊云科技的区域和可用区概念解释
  19. 微信收到的文件怎样通过电脑打印
  20. 转:大数据面试之_01_IT 从业人员面试小技巧

热门文章

  1. BZOJ1607 [Usaco2008 Dec]Patting Heads 轻拍牛头 筛法
  2. 迭代式客户端-服务系模型
  3. 使用DOM操纵样式表
  4. ubuntu 下LAMP服务器环境搭建
  5. LeetCode-Largest Rectangle in Histogram
  6. C#中调用SSIS包的问题
  7. 安装和运行Maven
  8. 由浅至深 谈谈.NET混淆原理 (四) -- 反混淆(原理 + 工具篇)
  9. javascript问题积累
  10. 关于在WinForm里用HttpWebRequest获得某个页面,并填写页面的textbox及点击button的方法...