love1point
love1point

Reputation: 1

Import package from PYPI

I use the "pip install xxx" from PYPI (https://pypi.python.org/pypi). Then I type "import xxx", it can import package without any problem.

However, when I uploaded my package to PYPI, Then I type "import xxx", it cannot import package. It said "ImportError, no module named xxx".

I think it is because the package is not my current directory? If yes, how should I do to avoid this problem when I uploaded my package to PYPI? Thanks.

Upvotes: 0

Views: 3823

Answers (1)

Peter Kilczuk
Peter Kilczuk

Reputation: 583

Your package does not contain any (valid) Python packages. Python package by definition has to have a __init__.py. Just put an empty __init__.py inside the mypackagemx3292016 folder.

I would however suggest not to use a package but rather just a single module. A package works good when you need to group multiple modules together. A simple example from distutils docs shows how to list individual modules.

In terms of installation you need to do exactly the same as with any other package:

pip install mypackagemx3292016

If you want to avoid the hassle of having to do this every time you upload a new version to pypi, you can symlink the local copy:

pip install -e /path/to/mypackagemx3292016

If that does not work there is probably a problem with your setup.py.

Upvotes: 1

Related Questions