I am having trouble getting Pydev to see a module in an import statement. I must be doing something stupid, but I can't figure it out.
I have .pth file in my C:\Python24 folder that contains:
D:\pythoncommon
D:\pythoncommon\pydispatch
When I configure an interpreter I see both of these folders as candidates for the System PYTHONPATH and I check them both.
When I import something from D:\pythoncommon then Pydev accepts it ok, but when I try to import something from D:\pythoncommon\pydispatch then Pydev gives me an unresolved import error.
When I F9 run the code it works - so the import is being resolved correctly at run-time.
I have tried this with and without PYTHONPATH environment variables, I have run Eclipse -clean and I have removed and re-istalled the Python interpreter. Many times for all of these things!
Don.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Upon further investigation it seems to be something to do with having my package in a lower-level folder.
I moved the contents of D:\pythoncommon\pydispatch to a new top-level folder D:\pydispatch, adjusted the .pth file, cleaned eclipse, re-installed the Python interpreter and now my import statement works as expected.
I don't really want to clutter up my top-level folder structure like this, so I would still like to know if there is a better solution.
TIA. Don.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You should only add the D:\pythoncommon\pydispatch to your project pythonpath. That's a thing with python... you can not have one source inside of the other (because it will go for the one it resolves first).
Cheers,
Fabio
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am having trouble getting Pydev to see a module in an import statement. I must be doing something stupid, but I can't figure it out.
I have .pth file in my C:\Python24 folder that contains:
D:\pythoncommon
D:\pythoncommon\pydispatch
When I configure an interpreter I see both of these folders as candidates for the System PYTHONPATH and I check them both.
When I import something from D:\pythoncommon then Pydev accepts it ok, but when I try to import something from D:\pythoncommon\pydispatch then Pydev gives me an unresolved import error.
When I F9 run the code it works - so the import is being resolved correctly at run-time.
I have tried this with and without PYTHONPATH environment variables, I have run Eclipse -clean and I have removed and re-istalled the Python interpreter. Many times for all of these things!
Don.
Upon further investigation it seems to be something to do with having my package in a lower-level folder.
I moved the contents of D:\pythoncommon\pydispatch to a new top-level folder D:\pydispatch, adjusted the .pth file, cleaned eclipse, re-installed the Python interpreter and now my import statement works as expected.
I don't really want to clutter up my top-level folder structure like this, so I would still like to know if there is a better solution.
TIA. Don.
You should add neither to your system pythonpath.
You should only add the D:\pythoncommon\pydispatch to your project pythonpath. That's a thing with python... you can not have one source inside of the other (because it will go for the one it resolves first).
Cheers,
Fabio
Doh! I forgot all about the project PYTHONPATH.
Thanks,
Don.