简体   繁体   English

从Github下载的模块未导入

[英]Module Downloaded from Github not Importing

I'm trying to create my own python package on Github so I can install it on any machine. 我正在尝试在Github上创建自己的python软件包,以便可以将其安装在任何计算机上。 It's installing and the module is there when doing pip3 freeze but there is an import error. 正在安装,执行pip3 freeze时模块在那里,但存在导入错误。

I've searched for "import error with module in pip" and couldn't find a relevant article specifically addressing this issue. 我搜索了“ pip中的模块导入错误”,但找不到专门解决此问题的相关文章。

Here are my terminal commands: 这是我的终端命令:

>>>sudo -H pip3 install git+git://github.com/iethan/machine_learning.git
Collecting git+git://github.com/iethan/machine_learning.git
Cloning git://github.com/iethan/machine_learning.git to /private/tmp/pip-kupvue2i-build
Installing collected packages: machine-learning
Running setup.py install for machine-learning ... done
Successfully installed machine-learning-0.0.1

When I try to import it there is an error: 当我尝试导入它时,出现错误:

Traceback (most recent call last):
  File "test_staging.py", line 1, in <module>
import machine_learning
ImportError: No module named 'machine_learning'

There must be something wrong with my setup file but I'm not sure what it is. 我的安装文件一定有问题,但是我不确定它是什么。

Update 更新

The issue was in the setup file. 问题出在安装文件中。

  packages=['MachineLearning']

Should have been: 本来应该:

  packages=['MachineLearning',
            'MachineLearning.get_data',
            "MachineLearning.pre_processing",
            "MachineLearning.train_test_optimize"],

You have: Installing collected packages: machine-learning And then : import machine_learning 您具有:安装收集的软件包:machine-learning,然后:import machine_learning

Try to rename module to machinelearning. 尝试将模块重命名为机器学习。 I think you mixed up some special characters. 我认为您混合了一些特殊字符。

The module is called MachineLearning . 该模块称为MachineLearning But it lacks __init__.py. 但是它缺少__init__.py。 It seems there are too many bugs in the package, it's not ready yet to be installed. 程序包中似乎有太多错误,尚无法安装。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM