问题描述
I already referred these posts 1, 2, 3, 4, 5
,但仍然无法解决此问题.可能是因为其他问题过于技术性.
but am still unable to fix this issue. Might be because the other issues are too technical.
我做了以下
a)我启动了jupyter笔记本(将文件保存在桌面中)
a) I launched the jupyter notebook (save the file in Desktop)
b)导入了常规软件包,例如Pandas,Numpy,Scipy等.
b) Imported regular packages like Pandas, Numpy, Scipy etc.
c)后来我尝试导入 Utils
和 Generators
程序包,但这引发了错误.
c) Later I tried importing Utils
and Generators
package but it threw error.
pip install Utils #success
pip install Generators #success
pip list-v #returned the below location
utils 1.0.1 c:\users\test\appdata\local\continuum\anaconda3\lib\site-packages pip
generators 2020.4.27 c:\users\test\appdata\local\continuum\anaconda3\lib\site-packages pip
When I tried importing `Utils` and `Generators` package, I get the same error as well
import psycopg2
import pandas as pd
import numpy as np
import Utils
import Generators
ModuleNotFoundError: No module named 'Utils'
ModuleNotFoundError: No module named 'Generators'
导入 Utils
包是否需要其他文件?
Does importing Utils
package require any other file?
为什么人们经常谈论成功导入utils的项目目录?我只是想像 Pandas
那样导入它,而不在乎项目目录.我刚刚启动了jupyter笔记本,并尝试安装 Utils
软件包
Why is that people often talk about project directory for importing utils successfully? I am just trying to import it like Pandas
which doesn;t care about project directory. I just launched a jupyter notebook and trying to install Utils
package
如何成功导入这些软件包?这些软件包不能像 pandas
这样的常规软件包那样导入吗?因为我安装了所有那些全新的软件包,并且都成功导入了
How can I import these packages successsfully? can't these packages be imported like regular packages such as pandas
? Because I installed all those packages brand new and they all are imported successfully
我也在此 import python_utils 但没有帮助
任何有关如何解决此问题的教程或步骤对我的学习都是非常有帮助的.
Any tutorial or steps on how can this be resolved would really be helpful for me to follow.
推荐答案
import
语句是区分大小写的,而 pip
是不区分大小写.
import
statements are case sensitive while the pip
is case insensitive.
根据 PEP-0426
描述了一种发布和交换与Python发行版/软件包相关的元数据的机制,
According to PEP-0426
which describes a mechanism for publishing and exchanging metadata related to Python distributions/packages,
因此从技术上讲, pip install Utils
, pip install UTILS
或 pip install utils
都将安装名为 utils的相同发行版/软件包.
.
So technically pip install Utils
, pip install UTILS
or pip install utils
will all install the same distribution/package named utils
.
要解决此问题,您必须将代码从更改为
To fix the problem you have to change your code from
import Utils
import Generators
到
import utils
import generators
这篇关于无法导入实用程序和生成器包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!