I'm probably doing something really dumb here, but it's driving me crazy.
I have two PyDev projects in Eclipse. One project, 'Analysis' depends on the other, 'PyCommon'. I'm 100% sure of this as when I look at the project references for Analysis, PyCommon is checked, and automatic import/code completion works when I reference elements in PyCommon from Analysis.
I'm trying to write/run a module in Analysis. The module is fhb/analysis/log_parsers.py.
I'm trying to import the element OrderStatus from fhb/pycommon/types/order_status in the PyCommon project. So, my import statement is
'from fhb.pycommon.types.order_status import OrderStatus'
PyDev clearly knows where this is because that import statement was written automatically by PyDev on a quickfix correction. Nonetheless, when I try to run the main function in log_parsers.py, I get this:
Traceback (most recent call last): File "/workspace/Analysis/src/fhb/analysis/log_parsers.py", line 6, in from fhb.pycommon.types.order_type import OrderType ImportError: No module named pycommon.types.order_status
All of these packages are under a proper source folder ('src') in each project.
Also, even though Analysis absolutely is set to reference PyCommon , when I look under PyDev-PYTHONPATH in Analysis's properties, only Analysis's own src folder appears under the 'Source Folder' tab, and it's the only project I see if I click on 'Add source folder'
The best way to check where the problem lies is by putting:
import sys
print('\n'.join(sorted(sys.path)))
in the entry of your program to see if the PYTHONPATH is properly set as you expect...
See: Importing from another project in pydev for details on how the structure is supposed to look like (in the worst case, if it's already configured, it could be a PyDev cache bug -- restarting Eclipse would fix it in this case -- otherwise, it's probably some misconfiguration).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With