I want to use PyCharm with IDAPython. I setup the Python Interpreter by adding the following path to the "Interpreter Paths":
C:\Program Files\IDA Pro 7.7\python\3
After that, it recognize the modules idaapi and idautils which is a good sign.
I wrote a simple scripts to test it:
import idaapi
import idautils
filename = idaapi.get_input_file_path()
I set a breakpoint on the filename... row and it failed with:
Traceback (most recent call last):
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 790, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "C:\Program Files\IDA Pro 7.7\python\3\ida_hexrays.py", line 12, in <module>
import _ida_hexrays
ModuleNotFoundError: No module named '_ida_hexrays'
It doesn't recognize the modules _ida_hexrays. How can I make it work?
I see that there is a file: C:\Program Files\IDA Pro 7.7\python\3\ida_64\_ida_hexrays.pyd.
In the ida_hexrays.py it throws the error when it try to import it like that:
# Import the low-level C/C++ module
if __package__ or "." in __name__:
from . import _ida_hexrays
else:
import _ida_hexrays
Related
After I converted my python project with NUITKA and I started running the following message appeared:
Owlready2 * Warning: optimized Cython parser module 'owlready2_optimized' is not available, defaulting to slower Python implementation
Traceback (most recent call last):
File "/user/try.dist/try.py", line 1, in <module>
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "/user/try.dist/owlready2/__init__.py", line 35, in <module owlready2>
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "/user/try.dist/owlready2/reasoning.py", line 41, in <module owlready2.reasoning>
FileNotFoundError: [Errno 2] No such file or directory: '/user/try.dist/owlready2/pellet'
Indicating that after I compiled the program some files were not found.
The code that I run was python3 -m nuitka --follow-imports --enable-plugin=numpy --onefile try.py
and the code that I compiled was just simple this:
from owlready2 import *
onto = get_ontology("file:///user/ontologies/try.owl").load()
with onto:
types.new_class("Drug", (Thing,))
onto.save()
So simple there was something wrong with the library.
If anyone knows what to do it will be helpful.
Thanks in advance.
I have changed the location of the file for privacy
I am trying to utilise a .NET6 library that depends on System.Text.Json which is failing to import using pythonnet:
Traceback (most recent call last):
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ModuleNotFoundError: No module named 'System'
In python, inspecting the assemblies pythonnet has added by default, it can be seen that it does not ship with the System.Text.Json namespace loaded:
import clr
print("[", ", ".join(clr.ListAssemblies(False)), "]")
Outputs:
[ mscorlib, clrmodule, Python.Runtime, System.Core, System.Configuration, System.Xml, System, __CodeGenerator_Assembly, e__NativeCall_Assembly ]
I then try to add System.Text.Json, which appears to succeed:
import clr
import sys
DOTNET_PATH: str = {YOUR PATH TO .NET6 DLLs}
sys.path.append(DOTNET_PATH)
clr.AddReference("System.Text.Json")
print("[", ", ".join(clr.ListAssemblies(False)), "]")
Outputs:
[ ..., System, System.Text.Json, System.Runtime, ... ]
However, trying to import a class from the namespace:
from System.Text.Json import JsonDocument
Continues to raise:
Traceback (most recent call last):
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ModuleNotFoundError: No module named 'System'
(I have also tried adding every .dll that ships with .NET 6.0.1 with no success)
Is there some other mechanism I need to utilise to successfully import from this namespace? (And associated)
To use .NET Core/.NET 5+ assemblies you need pythonnet 3.0.0 or later (currently in preview).
You also need to explicitly load coreclr:
from clr_loader import get_coreclr
from pythonnet import set_runtime
coreclr = get_coreclr("/full/path/to/app.runtimeconfig.json")
set_runtime(coreclr)
// here goes the rest of your code
runtimeconfig.json file is created by dotnet publish
I'm tyring to use this program (https://github.com/tbabej/uadt) to test my pcap captures and do some machine learning. I use the command git clone to have everything on my pc, then I use "pip -r install requirements.txt" and then I execute "setup.py install".
Then I need to generate my dataset, so I go to /uadt/uadt/analysis/ and run dataset.py as stated in the Readme, but I get the error
from uadt import config
ImportError: cannot import name 'config' from 'uadt'
What am I doing wrong? Is there another way to install it?
I just need the files in the analysis folder because I've already done the other steps on my own.
Traceback (most recent call last):
File "/usr/local/bin/uadt-dataset", line 33, in <module>
sys.exit(load_entry_point('uadt==0.8.0', 'console_scripts', 'uadt-dataset')())
File "/usr/local/bin/uadt-dataset", line 25, in importlib_load_entry_point
return next(matches).load()
File "/usr/lib/python3.9/importlib/metadata.py", line 77, in load
module = import_module(match.group('module'))
File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/usr/local/lib/python3.9/dist-packages/uadt-0.8.0-py3.9.egg/uadt/analysis/dataset.py", line 26, in <module>
from uadt.analysis.flow import Flow
File "/usr/local/lib/python3.9/dist-packages/uadt-0.8.0-py3.9.egg/uadt/analysis/flow.py", line 13, in <module>
from uadt import config
ImportError: cannot import name 'config' from 'uadt' (/usr/local/lib/python3.9/dist-packages/uadt-0.8.0-py3.9.egg/uadt/__init__.py)
You can copy the config.py.in file into the uadt folder.
This could fix your import issue.
i'm trying to use slicereg (https://github.com/brainglobe/slicereg) for data registration.
after import code from github page and install poetry to run slicereg i keep getting the following error :
The virtual environment found in ~\.conda\envs\sliceregenv seems to be broken.
Recreating virtualenv slicereg-6kSWvOuc-py3.8 in ~\AppData\Local\pypoetry\Cache\virtualenvs\slicereg-6kSWvOuc-py3.8
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "~\.conda\envs\sliceregenv\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 843, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "~\slicereg\slicereg\main.py", line 3, in <module>
from PySide2.QtWidgets import QApplication
ModuleNotFoundError: No module named 'PySide2'
Pyside2 is already installed in my env using pip.
Any advice on how to resolve this issue ?
Thx
Seems to be an issue, poetry fails to recognize conda environments as valid
see more at https://github.com/python-poetry/poetry/issues/4566
Remain unresolved for the current release (1.1.12)
Update : https://github.com/python-poetry/poetry/issues/5907
Running this code in normal IDLE is completely fine.
import OpenGL.GL as gl
However in VSCode, I get an import error.
No module named 'OpenGL.GL'; 'OpenGL' is not a package
File "C:\Users\Fluffy\Desktop\OpenGL.py", line 1, in <module>
import OpenGL.GL as gl
File "C:\users\fluffy\desktop\<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\users\fluffy\desktop\<frozen importlib._bootstrap_external>", line 678, in exec_module
File "C:\users\fluffy\desktop\<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "C:\users\fluffy\desktop\<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "C:\users\fluffy\desktop\<frozen importlib._bootstrap>", line 971, in _find_and_load
File "C:\users\fluffy\desktop\<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\users\fluffy\desktop\<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked
File "C:\users\fluffy\desktop\<frozen importlib._bootstrap>", line 971, in _find_and_load
File "C:\Users\fluffy\Desktop\OpenGL.py", line 1, in <module>
import OpenGL.GL as gl
Furthermore, I uninstalled PyOpenGL and noticed that VSCode's intellisense found an existing OpenGL module within python:
link
I'm pretty sure it has something to do with VSCode's way of importing modules from python.
NOTE: I tried reinstalling the PyOpenGL in many different ways, the error still persists.