Reputation: 8922
pip install git+git://github.com/BillMills/python-package-example.git
Looking at the directory structure at
..\PythonApplication\PythonApplication\env\Lib\site-packages\myPackage
and
import myPackage
foo = 6
bar = 7
When I run this I get the following error:
ModuleNotFoundError: No module named 'somePython'
What did I miss?
Based on Saurav's comment below I re-did the steps. However, after creating the environment I did activate it at the command prompt and ran the pip command inside the activated environment instead of the command prompt. The results did not change.
Someone else commented that github.com/BillMills/python-package-example.git is written in Python 2 and will not work in Python 3. If that is correct, what needs to be changed?
Upvotes: 0
Views: 1547
Reputation: 2246
The package you are using from https://github.com/BillMills/python-package-example is using an import style not supported in Python 3. You can see in python-package-example/__init__.py that
import somePython
is used to import a submodule, but python 3 will assume somePython
exists as a top level module. See PEP-328 for a better explanation.
A Python 3 compatible example package can be found at https://github.com/kennethreitz/samplemod. Notice that in sample/__init__.py submodules are imported using a relative import (indicated by the leading '.'):
from .core import hmm
If you wanted to modify python-package-example to be compatible you would need to change its __init__.py to use an absolute import:
import myPackage.somePython as somePython
or a relative import:
from . import somePython
Upvotes: 2