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.
Related
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
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.
I'm fairly new to python, but can't seem to get my head around this error - have found posts with similar issues, but none of the responses have helped.
I'm running Python 3.4.0 and have installed a module called lxml.
I wrote some code which starts
from lxml import html
This runs perfectly well from the python.exe interface, and the module can be used to succesfully import and parse XML.
However, if I save the script as a *.py file, and try to call it from a cmd.exe prompt, I get the ImportError: No module named lxml error.
Python is within C:\Python34, and the relevant module is located in C:\Python34\Lib\site-packages\lxml, which contains the required __init__.py
file.
I've checked sys.path which, amongst others, holds C:\\Python34\\lib\\site-packages
The double-backslashes and lowercase 'l' in 'lib' shouldn't make a difference, should it? All listed paths appear to have double-backslashes instead of single.
I did attempt to add the path with an uppercase 'L' using
sys.path.insert(1, 'C:\Python34\Lib\site-packages')
which subsequently appeared as a seperate path, however did not resolve the issue.
Additionally, I replaced the first line of my script with
import sys
sys.path.append('C:\Python34\Lib\site-packages')
which appeared to attempt to read the required __init__.py file (progress!!!), but then gave the following error: ImportError: Module use of python34.dll conflicts with this version of Python, so I probably won't pursue this avenue, unless it is of relevance.
Any idea what I'm doing wrong with regards to ImportError: No module named lxml?
I'm creating a Python library file from C++ using Boost::Python, and I'm trying to import it from the Python command line to test it.
The module seems to work correctly when imported, but only if it is named .so. If the same exact file is renamed to .pyd, in the same directory, the console replies with an
ImportError: No module named Test
I have also tried to rename it with a trailing _d in case the console was in debug mode, but that does not seem to be the case.
What could be the problem?
A noob python question.
I have a package called TorCtl, I saved it in /root/A and create a file (useIt.py) in /root/A which uses the package and it works absolutely fine.
now the problem starts when I try to use this package within another project.
I copied TorCtl package into /root/B/C and created a new file (useIt2.py) (this file is used from another file that is the main for this package.)
when I run main I get import error from TorCtl package. for example:
from elixir import *
ImportError: No module named elixir
I have no idea why it should work in one folder and not another.
Can anyone point out what I am doing wrong please?