0

I'm trying to create my own python package on Github so I can install it on any machine. It's installing and the module is there when doing pip3 freeze but there is an import error.

I've searched for "import error with module in pip" and couldn't find a relevant article specifically addressing this issue.

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"],
ethanenglish
  • 1,217
  • 2
  • 15
  • 32

2 Answers2

0

You have: Installing collected packages: machine-learning And then : import machine_learning

Try to rename module to machinelearning. I think you mixed up some special characters.

0

The module is called MachineLearning. But it lacks __init__.py. It seems there are too many bugs in the package, it's not ready yet to be installed.

phd
  • 82,685
  • 13
  • 120
  • 165