linux/cmd中python路径导入ModuleNotFoundError: No module named 'xxx' import osimport syscurPath = os.path.abspath(os.path.dirname(__file__))rootPath = os.path.split(curPath)[0]print(rootPath)sys.path.append(os.path.split(rootPath)[0]) from sendWeatherEma
解决方法有两种 1. 第一种设置环境变量法 on windows the line is : SET PYTHONPATH=%cd%;%cd%\Test NOT SET PYTHONPATH=%cd%:%cd%\Test You can test with : echo %PYTHONPATH% 2.第二种方法 进入 python 运行环境 import sys import os curPath = os.path.abspath(os.path.dirname(__file__))
一.安装tkinter 在Linux中python默认是不安装Tkinter模块, [root@li250- ~]# python Python (r266:, Feb , ::) [GCC (Red Hat -)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import Tkint