I have created a separate file to hold some custom issue classes for my Python file and upon execution of the following command: coverage run test_syntax.py it prints out the following error as seen in this Travis CI build:
Traceback (most recent call last):
File "test_syntax.py", line 9, in
from ros import main as s
File "/home/travis/build/Richienb/ROS-Code/src/ros/main.py", line 57, in
from errors import ConversionError, WrongInput, UnexpectedError
ModuleNotFoundError: No module named 'errors'
You can find all of the code here
Also, I have already cd into the src directory.
You need a relative import like this (second one was needed on my machine to even get to the error you have posted):
# in main.py
from .errors import ...
# ros.py
from . import errors
Related
So, I created a small flask API. Basically a wrapper for another API.
I used requests-futures to send multiple calls asynchronously.
I set up my virtual environment. Everything works exactly as I intend. However, when I try to run some tests I've written (using python -m unittest) this is the error I get:
======================================================================
ERROR: test (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: test
Traceback (most recent call last):
File "/usr/lib/python3.8/unittest/loader.py", line 436, in _find_test_path
module = self._get_module_from_name(name)
File "/usr/lib/python3.8/unittest/loader.py", line 377, in _get_module_from_name
__import__(name)
File "/home/cwverica/take-home-apps/quixr/test.py", line 2, in <module>
from app import app, session
File "/home/cwverica/take-home-apps/quixr/app.py", line 3, in <module>
from requests_futures.sessions import FuturesSession
ModuleNotFoundError: No module named 'requests_futures'
I have reinstalled the module using pip. I made sure to pip freeze > requirements.txt just in case it was reading module availability from there. But all in all I'm stumped. If anyone could help me out here, I'd greatly appreciate it.
I'm using PyCharm for a project with the following file hierarchy:
And I'm running main.py in PyCharm with the following configurations:
Working Directory: /Users/me/longpath/project/amlproject/pca_mixtures.
When I try to run in terminal, it fails:
~/longpath/project/amlproject/pca_mixtures$ python main.py
Traceback (most recent call last):
File "main.py", line 2, in <module>
from pca_mixtures.funcs import PCAMixture
ModuleNotFoundError: No module named 'pca_mixtures'
and nothing changes if I jump up to the parent folder:
~/longpath/project/amlproject$ python pca_mixtures/main.py
Traceback (most recent call last):
File "pca_mixtures/main.py", line 2, in <module>
from pca_mixtures.funcs import PCAMixture
ModuleNotFoundError: No module named 'pca_mixtures'
The reason for using from pca_mixtures.funcs import PCAMixture instead of just from funcs import PCAMixture was so that PyCharm would recognize the import and not red-underline it, as I've described here. Now, it seems that this has lead to me not being able to run the project in the terminal.
How would you handle this? I want to be able to run it in the terminal because the PyCharm output is not fully sequential (error messages output before program output) which is annoying when debugging.
In demo.py of this project, there is one line of code sys.path.insert(1, 'incl'). After running this line of code, we can see that sys.path has added one more extra item 'incl'. As shown from the github project, we can see there is a subfolder named as 'incl' containing some path information. I can guess that with the help of sys.path.insert, we should be able to include these path information, but running from seg_utils import seg_utils as seg fails by giving the error message of. My estimation is that 'incl' was not correctly imported into sys.path.
Traceback (most recent call last):
File "demo.py", line 52, in <module>
from seg_utils import seg_utils as seg
ImportError: No module named seg_utils
I can't import the sompy module even though I installed it successfully, and it appears in the modules list of my python environment:
When I try to import the sompy module using the following statement:
import sompy
I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'sompy'
What's wrong?
Which interpreter/IDE are you using? If using PyCharm, the problem could be that PyCharm hasn't identified a root folder for your .py project.
I would try and recreate the root folder as a subfolder and right click > Make source directory.
the question is may be similar to this one, but did not solve my issue and also is somehow much stranger:
I got a strange problem, where when executing only my python file from command line:
>python main.py, everything works. But when using it with blender like this:
blender -b ..\test.blend --pyhton ..\main.py
i get this error (file paths are substituted with ..) :
Traceback (most recent call last):
File "\\...\Blender\2.78\python\lib\site-packages\numpy\core\__init__.py", line 16, in <module>
from . import multiarray
ImportError: DLL load failed: Die angegebene Prozedur wurde nicht gefunden.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "...\main.py", line 4, in <module>
import numpy as np
File "\\...\Blender\2.78\python\lib\site-packages\numpy\__init__.py", line 142, in <module>
from . import add_newdocs
File "\\...\Blender\2.78\python\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "\\...\Blender\2.78\python\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
from .type_check import *
File "\\...\Blender\2.78\python\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "\\...\Blender\2.78\python\lib\site-packages\numpy\core\__init__.py", line 24, in <module>
raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control). Otherwise reinstall numpy.
AL lib: (EE) UpdateDeviceParams: Failed to set 44100hz, got 48000hz instead
my main.py looks like this:
#import bpy
import sys
import numpy
import h5py
...more imports...
if __name__ == "__main__":
logging.info("No error")
The story I told so far, is fact, when I run the blender and python from a HTCondor Windows node. Again, only the python file works fine, but when including blender the DLL error occurs.
Additionally I tested everything before on my local PC where both variations work without issues, using exactly the same files! (Everything is located on a NAS drive)
There must be some linkage to some python stuff on my pc. I only have the miniconda3 directory, which i completely removed so blender can use the bundled one.
Hopefully somebody can help me and please feel free to ask for stuff I failed to explain.
EDIT:
The multiarray module is located in the numpy.core folder with the name mutliarray.cp35-win_amd64.pyd, which makes no sense to me why the module is found on my local PC but not on the HTCondor windows node.
EDIT 2:
According to sampler's suggestions I tried the following:
1) I used getenv = True in the submission file to submit the locally working environment with the job. Result: Does not work either.
2) I cleared all environment variables except those needed for running correctly on my local pc. Clearence happend with this lines:
for i in os.environ:
os.environ[i] = ""
The only used variable is set:
os.environ["PATH"] = "\\\\[servername]\\conda\\Blender\\2.78\\python\\Library\\bin;"
without this line I get the same multiarray import error on my local pc.
These lines are executed in my main.py script but still does not change anything when running on the condor node.
Even stranger is the fact, that running only the python script on the condor node works perfektly fine, but just running it with blender (as shown in the first codeline of this post), results in the multiarray import error.