当前位置:网站首页>自己创建的模块 使用cmd打开报 ModuleNotFoundError: No module named 解决方案
自己创建的模块 使用cmd打开报 ModuleNotFoundError: No module named 解决方案
2022-07-17 11:14:00 【佛系的老肖】
我有这样一个项目脚本文件

这里 main.py 为我的程序主入口,在pycharm 可以正确运行,在cmd 就会报这样的错误

解决方法:
定位找不到模块位置:
这里我是报的Freight这个模块找不到
需要将 Freight 模块的上级目录添加到路径中
import sys
import os
curPath = os.path.abspath(os.path.dirname(__file__))
rootPath = curPath.split("\Freight")[0]
sys.path.append(rootPath)
这里的rootpath 则为 :
C:\Users\Administrator\PycharmProjects\pythonProject1
这段代码放置在主入口脚本的导入模块语句上方

再次在CMD中运行就不会报错了

边栏推荐
- 浏览器的故事
- 纳米银颗粒负载UiO-66|Fe3O4/Cu3(BTC)2金属有机骨架(MOF)纳米复合材料|NaGdF4:Yb,Er上转换纳米粒子@ZIF-8
- Es restful operation
- Talking about the informatization planning of industrial enterprises
- [C language] storage of shaping data
- Duilib implements tooltip custom mouse prompt window
- Part I - Fundamentals of C language_ 2. Data type
- mof定制材料|超薄MOF纳米带|磁性Fe3O4 @Cd-MOF纳米复合材料|ZIF-8/石墨烯复合纳米颗粒
- Chapter 4 - consistency of first-order multi-agent systems - > consistency of continuous time systems with time delays
- Series operation of vector container (detailed explanation)
猜你喜欢

node+express搭建服务器环境

第一部分—C语言基础篇_3. 运算符与表达式

第十章 STL 之 stack
二维数组与稀疏数组之间的转换

Anaconda and jupyter notebook entry level detailed tutorial

MySQL -- SQL optimization case -- implicit character encoding conversion
![[C language] void type and void* pointer type](/img/4c/3643d850bfcb57db93496ec9bba06e.png)
[C language] void type and void* pointer type

标准化、归一化和正则化的关系

Rhcsa the next day 7.15

es索引、类型(mapping)、文档、ik分词器
随机推荐
实验1:使用Matlab工具箱进行相机标定实验
mof定制产品|N-K2Ti4O9/g-C3N4/UiO-66三元复合材料|纸基Au-AgInSe2-ZIF-8纳米复合材料
第一部分—C语言基础篇_4. 程序流程结构
ES6中的let、const、var
Chapter 4 - consistency of first-order multi-agent systems - > consistency of continuous time systems with time delays
金属有机骨架材料/聚合物复合材料ZIF-8/P(TDA-co-HDA)|氧化锌[email protected](Fe)复合纳米材料
对文本实现分词以及绘制词云
Convert video format to GIF picture format
Vim详解
第十二章 STL 之 list
[动态规划]DP27 跳跃游戏(二)-中等
rhcsa 第二天 7.15
Chapter 12 list of STL
2022.7.16-----leetcode. Sword finger offer 041
标准化、归一化和正则化的关系
Clwy permission management (I) -- project construction
mof定制材料|双金属CuNi-MOF纳米材料|核—壳结构[email protected]纳米复合材料|ZIF-8/聚偏氟乙烯复合纳米纤维膜PVDF
CLWY权限管理(一)--- 项目搭建
506.相对名次
一汽丰田亚洲狮首次产品焕新