北冰洋 wrote: > I just wrote a sample like this: > testPy/ > __init__.py > client.py > SoamFactory.c > SoamFactory.so > soamapi.py > sample/testP.py > export PYTHONPATH=$(TEST_LOCATION):$(TEST_LOCATION)/testPy
> I found that soamapi was imported twice, and I investigated this is > I don't know how to fix it. Is there any official way about how to porting > this scenario or better idea? Without looking into the details -- I believe that your problem stems from having a path into the package: > export PYTHONPATH=$(TEST_LOCATION):$(TEST_LOCATION)/testPy The above means that a module testPy.foo can also successfully be imported as foo. Try changing the path to export PYTHONPATH=$(TEST_LOCATION) If you get failing imports change every failing import import foo to from testPy import foo -- https://mail.python.org/mailman/listinfo/python-list