Import error using Python uadt package (machine learning) - python

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.

Related

Issue with virtualenv/mkvirtualenv/pip - "zsh: /usr/local/bin/pip: bad interpreter: /usr/local/opt/python#2/bin/python2.7: no such file or directory"

I'm trying to create a new virtualenvironment for some repos but seem to be running into a bunch if issues in my terminal, these are the errors I get:
zsh: /usr/local/bin/pip: bad interpreter: /usr/local/opt/python#2/bin/python2.7: no such file or directory
OR this issue:
ERROR: It thinks sys.prefix is '/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7' (should be '/Users/USERNAME_HERE/.virtualenvs/returns-backend')
ERROR: virtualenv is not compatible with this system or executable
I get this error when running: brew link --overwrite python from here
Linking /usr/local/Cellar/python/3.7.7... Error: Cannot link python
Another version is already linked: /usr/local/Cellar/python/3.7.6_1
I also get this issue when running the following command: pip3 install --upgrade pip from this comment
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 11, in <module>
load_entry_point('pip==19.3.1', 'console_scripts', 'pip3')()
File "/usr/local/lib/python3.7/site-packages/pip/_internal/main.py", line 45, in main
command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
File "/usr/local/lib/python3.7/site-packages/pip/_internal/commands/__init__.py", line 96, in create_command
module = importlib.import_module(module_path)
File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/usr/local/lib/python3.7/site-packages/pip/_internal/commands/install.py", line 23, in <module>
from pip._internal.cli.req_command import RequirementCommand
File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/req_command.py", line 17, in <module>
from pip._internal.index import PackageFinder
ImportError: cannot import name 'PackageFinder' from 'pip._internal.index' (/usr/local/lib/python3.7/site-packages/pip/_internal/index/__init__.py)
I haven't touched the terminal in a long time (2+ years) and don't remember what I used to set these up as my documentation wasn't great last time when starting to code. I think I remember using brew before to set this stuff all up, but now I'm just worried about making any more changes that might break things even further.
Any help with commands that might not be as intrusive/possibly making this problem bigger?

OSError: /usr/lib/libyara.so: cannot open shared object file: No such file or directory

I have some issue trying to run Volatility 3 Framework.
git clone https://github.com/volatilityfoundation/volatility3.git
cd volatility3/
python3 vol.py ../ramdumps/1289.raw windows.pslist.PsList
I got this error traceback:
Volatility 3 Framework 2.0.0
Failed to import '/usr/lib/libyara.so'
PATH = /home/user/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/go/bin:/home/user/go/bin;/usr/lib
Traceback (most recent call last):
File "vol.py", line 10, in <module>
volatility3.cli.main()
File "/home/user/Documents/volatility3/volatility3/cli/__init__.py", line 625, in main
CommandLine().run()
File "/home/user/Documents/volatility3/volatility3/cli/__init__.py", line 229, in run
True) # Will not log as console's default level is WARNING
File "/home/user/Documents/volatility3/volatility3/framework/__init__.py", line 127, in import_files
ignore_errors)
File "/home/user/Documents/volatility3/volatility3/framework/__init__.py", line 152, in import_file
importlib.import_module(module)
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/user/Documents/volatility3/volatility3/framework/plugins/yarascan.py", line 17, in <module>
import yara
File "/home/user/.local/lib/python3.6/site-packages/yara/__init__.py", line 7, in <module>
from yara.rules import compile
File "/home/user/.local/lib/python3.6/site-packages/yara/rules.py", line 17, in <module>
from yara.libyara_wrapper import *
File "/home/user/.local/lib/python3.6/site-packages/yara/libyara_wrapper.py", line 315, in <module>
libyaradll = cdll.LoadLibrary(library)
File "/usr/lib/python3.6/ctypes/__init__.py", line 426, in LoadLibrary
return self._dlltype(name)
File "/usr/lib/python3.6/ctypes/__init__.py", line 348, in __init__
self._handle = _dlopen(self._name, mode)
OSError: /usr/lib/libyara.so: cannot open shared object file: No such file or directory
Someone already had the same error a few years ago but none of the answers worked for me.
I'm using python 3.6.9 and Xubuntu 18.04.6
You have to uninstall yara with pip. Only tara-python must be installed.
Did you install the requirements with
pip3 install -r requirements.txt
?

ModuleNotFoundError: No module named 'PySide2' while trying to use poetry env

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

pyttsx3 module is not giving any output

I'm having some troubles with the pyttsx3 module. At first I couldn't even initialize it and I got this error:
File "/home/emanuele/.local/lib/python3.9/site-packages/pyttsx3/__init__.py", line 20, in init
eng = _activeEngines[driverName]
File "/usr/lib/python3.9/weakref.py", line 137, in __getitem__
o = self.data[key]()
KeyError: None
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/emanuele/AllInOneApp.py", line 3, in <module>
engine = pyttsx3.init()
File "/home/emanuele/.local/lib/python3.9/site-packages/pyttsx3/__init__.py", line 22, in init
eng = Engine(driverName, debug)
File "/home/emanuele/.local/lib/python3.9/site-packages/pyttsx3/engine.py", line 30, in __init__
self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
File "/home/emanuele/.local/lib/python3.9/site-packages/pyttsx3/driver.py", line 50, in __init__
self._module = importlib.import_module(name)
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 "/home/emanuele/.local/lib/python3.9/site-packages/pyttsx3/drivers/espeak.py", line 3, in <module>
import ctypes
File "/usr/lib/python3.9/ctypes/__init__.py", line 8, in <module>
from _ctypes import Union, Structure, Array
ImportError: libffi.so.8: cannot open shared object file: No such file or directory
Then I solved it by running this two commands
pip uninstall pyttsx3
and
pip install pyttsx3==2.71
and adding to the init function the argument 'dummy'.
The problem is that now it runs without errors, but I don't get any output from the module
I finally got the solution. Refer below for the fix.
Run: sudo apt install libespeak1
Explanation: libspeak1 package is needed for running pyttsx3 in ubuntu.

ImportError: No module named 'zope' for cryptoassets.django while running the initialize database command

Okay, Im trying to use cryptoassets.django here. Iv got some help from Mikko about the python version being an issue(I was using 2.7.x, cryptoassets uses 3.4.x). I just solved by doing this
$virtualenv -p python3 venv
I also reinstalled Django because manage.py was pulling up error, probably because it was overwriting the bin/activate.. files.
With that out of the way. I installed the cryptoassets.django app
$pip3 install cryptoassets.django
Wonderfull. I set it up like the tutorial on bitbucket for the cryptoassets django intergration.
The problem comes in when i try to initialize the cryptoasset database with
$python manage.py cryptoassets_initialize_database
I get an Import error:
ImportError: No module named 'zope'
Here is the Traceback
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/caleb/Desktop/bitkoin/lib/python3.4/site- packages/django/core/management/__init__.py", line 351, in execute_from_command_line
utility.execute()
File "/home/caleb/Desktop/bitkoin/lib/python3.4/site-packages/django/core/management/__init__.py", line 343, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/caleb/Desktop/bitkoin/lib/python3.4/site-packages/django/core/management/__init__.py", line 190, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/home/caleb/Desktop/bitkoin/lib/python3.4/site-packages/django/core/management/__init__.py", line 40, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/home/caleb/Desktop/bitkoin/lib/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "<frozen importlib._bootstrap>", line 1471, in exec_module
File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
File "/home/caleb/Desktop/bitkoin/lib/python3.4/site-packages/cryptoassets/django/management/commands/cryptoassets_initialize_database.py", line 5, in <module>
from cryptoassets.core.service.main import Service
File "/home/caleb/Desktop/bitkoin/lib/python3.4/site-packages/cryptoassets/core/service/main.py", line 25, in <module>
from ..configure import Configurator
File "/home/caleb/Desktop/bitkoin/lib/python3.4/site-packages/cryptoassets/core/configure.py", line 13, in <module>
from zope.dottedname.resolve import resolve
ImportError: No module named 'zope'
What could be the issue now.
Cryptoassets is Python 3.4+ only and you are trying to run it on Python 2.

Categories

Resources