I am using PyDev.
I am trying to organise my project classes into packages.
e.g. In a folder I have a module at /libraries/fund_price_library.py
In another file in my project, I try to import using:
from libraries.fund_price_library import FundPriceLibrary as fpl
PyDev underlines "FundPriceLibrary as fpl" in red, marking it with this error:
unresolved import fpl
However, my script works perfectly fine, so I believe that I am doing the import correctly.
I have lots of similar errors all over my project, and it looks messy. However, my python code works, so I assume I am importing correctly.
How do I suppress these errors?
To solve unresolved import error in Python, set your Python path in your workspace settings. If you are working with Visual Studio Code and import any library, you will face this error: “unresolved import”. Then reload the VSCode, and it will fix that error.
An import and export each consist of a procedure or data type and a name. An unresolved import is one whose type and name do not yet match the type and name of an export. A resolved import is one whose type and name exactly match the type and name of an export.
Go to File → New → PyDev Project to start a wizard. In the next window that appears, enter the name of your project and select "python" and 3.0"; as the type. Make sure "create default 'src' folder and add it to the pythonpath?" is selected. Click Finish.
PyDev is a Python IDE for Eclipse, which may be used in Python, Jython and IronPython development. It comes with many goodies such as: Django integration. Code completion. Code completion with auto import.
This question might hold the solution to your problem.
In the properties for your pydev project, there's a pane called "PyDev - PYTHONPATH", with a sub-pane called "External Libraries". You can add source folders (any folder that has an init.py) to the path using that pane. Your project code will then be able to import modules from those source folders.
It might just be that PyDev doesn't know where to find the files.
I had the same issue. Solution is (I have Eclipse 4.6 w/ Pydev 5.6):
Project > Properties > PyDev - PYTHONPATH > tab Source Folders
Do this: Add source folder
(button) and add your (current) source dir, in my case it was src
subdir so new item apears in the window :
/${PROJECT_DIR_NAME}/src
So now I have this there:
/${PROJECT_DIR_NAME}
/${PROJECT_DIR_NAME}/src
and my PyDev is happy now :)
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