Pycharm says unresolved error when import but the code execute - python

I have a issue with Pycharm, that shows an error on importing local modules, even though it works.
The working code for import is
from response_generator import core
Pycharm suggests
from .response_generator import core
When executing what pycharm suggest. Error received is:
ModuleNotFoundError: No module named '__main__.response_generator'; '__main__' is not a package
Anyone got a fix on this?

Related

import argostranslate.translate says "no module named lzma"

I have installed "argostranslate==1.7.5"
but when i try calling import argostranslate.translate in centos i'm getting
ModuleNotFoundError: No moduel named '_lzma'
I have tried all the steps in https://stackoverflow.com/a/57773679 but noting helps.
Finally, it has worked when I try to run my app in python version 3.9.6.
I hope it will help someone sometime somewhere.

Python: ModuleNotFounderror: 'No module named image_downloader'

Code that worked for months suddenly stopped working.
In a file in the same directory 'downloaders', I have an import 'import image_downloader'. Somehow, the import doesn´t work anymore. The file that imports it is in the same directory.
My PyCharm IDE shows no problems at all, no warning or anything. But when I run it, the ModuleNotFoundError happens:
ModuleNotFoundError: No module named 'image_downloader'.
I have looked at similar questions here, but they haven´t helped me so far. I am desperate, and would be thankful for tips on resolving this annoying issue.
I found the solution. Not sure why it doesn´t work anymore with the old import style.
But what made it work: using absolute imports. This means in this case, instead of import image_downloader, I used from downloaders import image_downloader, even when the importing file is also in the package image_downloader.

How to fix ModuleNotFoundError in a Python file

I have a small issue regarding importing a class from another python file.
Here is the file that I try to import. The EvaluationDetect is a class from the evaluation_detect.py file. The file evaluation_detect.py is located into path
from oculus_evaluation.oculus_evaluation.evaluation_detect import EvaluationDetect
And Pycharm IDE always shows me this error message.
ModuleNotFoundError: No module named 'oculus_evaluation.oculus_evaluation'; 'oculus_evaluation' is not a package
Please I do not understand where is the wrong in this case. There is not possible to import a class. This a legacy code and I do not understand.

importing turtle module in VS Code gives ModuleNotFoundError: 'tkinter'

I am trying to import turtle module. but it shows me module name 'tkinter' is not found. although it is a built-in module.and i didnt import it directly.(i think turtle module imports tkinter for me.)
I tried changing the path for Python in VS Code by clicking the bottom left option is status bar.
other modules are getting imported(import random, etc)
I have attached the screenshot of the code and error i am getting.
Please HELPPP!!!!
It can also be an import error that you facing with you IDE (VS Code). Try changing the target exe to the python interpreter in your virtual environment. You can learn more about this, by visiting the link below:
https://medium.com/nerd-for-tech/import-errors-in-python-no-module-named-module-name-for-vs-code-887d1f78cf02

Import Error: Using Python with Geany

How can I add path to the PYTHONPATH environment variable
I tried using "sudo so" in .bash and also tried
export PYTHONPATH=$PYTHONPATH:/home/01_Understand/scitools/bin/linux32/python
but I am still getting import error.
I actually want to use Understand module (understand.py) with Geany but there is always an error stating
ImportError: No module named understand
Can anyone help me in this regard ?
Thanks

Categories