ImportError: I have made __init__.py file as well - python

I am having this error while I run the project:
from .miner import Miner
ImportError: attempted relative import with no known parent package
1--> init file, 2--> malicious miner.py which shoes the above-mentioned error.
As it is mentioned in the picture I have a module name miner, there is also init to make share the proper module import, I have double-checked the files but somehow this error is presenting. Can Someone please help me to solve this issue?
This is the init file:
from .miner import Miner
from .malicious_miner import MaliciousMiner
while importing it doesn't show any error but when I run the file

I strongly suggest you to use PyCharm. Creating and importing files from the IDE really helps a lot in this type of problems, because it's not only creating an init. I would like to help you further if using PyCharm won't solve the problem

Related

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.

Python:circular import

I am trying to develop a localhost website but now I got this error:
ImportError: cannot import name '_encode_idna' from partially initialized module 'werkzeug._internal' (most likely due to a circular import)
Could anyone help me? Thanks a lot.
You are writing code inside your Flask package. Move your code outside your environment.
You have created file website.py at the path Lib/site-packagese/Flask/ which is wrong. Move your project outside of Lib. More appropriate place would be you home directory or desktop or any other place but not Lib.

Python 2.7.9 troubles importing pysftp

I've been having troubles import pysftp. I currently have a server running some python scripts on a database, and decided to try and update this module which some of the scripts use. It broke a bunch of the scripts and then I had to go back and fix the versioning and to allow everything to function.
So far the only module I'm not able to import or use is pysftp. It throws the attached error. I've tried going into sites-manager and removing the files from there, however it has yet to help. Everything else has been working. Updating doesn't work either.
Any indication on how to resolve this error is greatly appreciated.
Error is:
ImportError: cannot import name util
I haven't been able to find a package called util to install. Please help! Attached link is of the trace.
http://imgur.com/a/9lQUj

CSjark: NameError name 'Platform' is not defined

I'm usually not working with Python (but have ability to read the code).
I'm trying to use csjark.
All the dependencies were installed correctly.
When executing csjark.py I'm receiving following error:
NameError name 'Platform' is not defined
The import is done with from platform import Platform
All the *.py files are located in the same folder.
I don't have any issue similar statements for other imports.
Importing with import platform is working, but latter I can't use any parameter from the class.
Please suggest ways to resolve the issue with the platform.py file.
Maybe your program is importing the wrong platform.py, for example this one:
https://docs.python.org/2/library/platform.html
which doesn't seem to have a Platform class. Try renaming the platform.py to something else and importing from that to see if this is the issue.

Categories