center-for-threat-informed-defense / tram

TRAM is an open-source platform designed to advance research into automating the mapping of cyber threat intelligence reports to MITRE ATT&CK®.

Home Page:https://ctid.mitre-engenuity.org/our-work/tram/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

tram not found

anust opened this issue · comments

commented

I am installing tram in developer's mod using git clone . I am stuck here.

tramvir) mitre@ubuntu:~/tram$ pre-commit install
pre-commit installed at .git/hooks/pre-commit

(tramvir) mitre@ubuntu:~/tram$ tram makemigrations tram

Command 'tram' not found, did you mean:

  command 'tran' from deb tran (5-2)

Try: sudo apt install

Hi @anust. Before running any tram command, you need to activate the virtualenv (see step 4 in README).

I'm faced whit the same error and aplided your solution (activate the virtualenv) and thats don't fix the error.

(venv) javi@ubuntu:~/Desktop/TRAM/tram/src/tram$ tram makemigrations tram

Command 'tram' not found, did you mean:

  command 'trax' from snap trax (1.0)
  command 'tran' from deb tran (5-2)

See 'snap info <snapname>' for additional versions.

(venv) javi@ubuntu:~/Desktop/TRAM/tram/src/tram$ 

What should we do to make it work?

PD. I'm not sure if command python manage.py makemigrations is equivalent. But it also generate an error.

(venv) javi@ubuntu:~/Desktop/TRAM/tram/src/tram$ python manage.py makemigrations
Traceback (most recent call last):
  File "/home/javi/Desktop/TRAM/tram/venv/lib/python3.8/site-packages/django/core/management/base.py", line 354, in run_from_argv
.
.
.
ModuleNotFoundError: No module named 'tram.settings'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    main()
  File "manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/home/javi/Desktop/TRAM/tram/venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
.
.
.
ModuleNotFoundError: No module named 'tram.settings'
(venv) javi@ubuntu:~/Desktop/TRAM/tram/src/tram$ 

@JaviFS97 It sounds like something went wrong in step 5. Try running it again.

pip install -r requirements/requirements.txt
pip install -r requirements/test-requirements.txt

The installation of the dependencies of requeriments.txt works correctly.

But when I try to install test-requeriments.txt dependencies generates the following message:

(venv) javi@ubuntu:~/Desktop/TRAM 1.2.0/tram$ pip install -r requirements/test-requirements.txt
ERROR: File "setup.py" not found. Directory cannot be installed in editable mode: /home/javi/Desktop/TRAM 1.2.0/tram
(A "pyproject.toml" file was found, but editable mode currently requires a setup.py based build.)
(venv) javi@ubuntu:~/Desktop/TRAM 1.2.0/tram$ 

There is not a setup.py file in the directory.

Hmm... The test-requirements.txt is working for me.

(venv) .../tram$ pip install -r requirements/test-requirements.txt
Obtaining file:///Volumes/Code/ctid/tram (from -r requirements/test-requirements.txt (line 14))
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
...snip...
Installing collected packages: tram
  Attempting uninstall: tram
    Found existing installation: tram 1.1.3
    Uninstalling tram-1.1.3:
      Successfully uninstalled tram-1.1.3
  Running setup.py develop for tram
Successfully installed tram-1.2.0
WARNING: You are using pip version 22.0.3; however, version 22.1.2 is available.
You should consider upgrading via the '/Volumes/Code/ctid/tram/venv/bin/python3.9 -m pip install --upgrade pip' command.

Can you tell me what OS you're using, OS version, Python version, and pip version? I am thinking maybe a newer pip version would fix this for you?

$ python --version
Python 3.9.12
$ pip --version
pip 22.0.3 from /Volumes/Code/ctid/tram/venv/lib/python3.9/site-packages/pip (python 3.9)
$ uname -av
Darwin MM278991-PC 21.4.0 Darwin Kernel Version 21.4.0: Fri Mar 18 00:45:05 PDT 2022; root:xnu-8020.101.4~15/RELEASE_X86_64 x86_64

I create a new virtual env (early I was working with 3.8 version of python) to have a version closer to yours. Even with this changes I have the same message as before.

(venv3.9) javi@ubuntu:~/Desktop/TRAM 1.2.0/tram$ pip install -r requirements/test-requirements.txt 
ERROR: File "setup.py" not found. Directory cannot be installed in editable mode: /home/javi/Desktop/TRAM 1.2.0/tram
(A "pyproject.toml" file was found, but editable mode currently requires a setup.py based build.)
(venv3.9) javi@ubuntu:~/Desktop/TRAM 1.2.0/tram$ python -V
Python 3.9.5
(venv3.9) javi@ubuntu:~/Desktop/TRAM 1.2.0/tram$ pip -V
pip 20.0.2 from /home/javi/Desktop/TRAM 1.2.0/tram/venv3.9/lib/python3.9/site-packages/pip (python 3.9)
(venv3.9) javi@ubuntu:~/Desktop/TRAM 1.2.0/tram$ uname -av
Linux ubuntu 5.13.0-35-generic #40~20.04.1-Ubuntu SMP Mon Mar 7 09:18:32 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Looks like it's the pip version. I installed 20.0.2 and got the same result as you, then upgraded to 22.1.2 and it works.

(venv) $ pip install pip==20.0.2
Collecting pip==20.0.2
  Downloading pip-20.0.2-py2.py3-none-any.whl (1.4 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.4/1.4 MB 16.8 MB/s eta 0:00:00
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 22.0.3
    Uninstalling pip-22.0.3:
      Successfully uninstalled pip-22.0.3
Successfully installed pip-20.0.2

(venv) $ pip install -e .       
ERROR: File "setup.py" not found. Directory cannot be installed in editable mode: /Volumes/Code/ctid/tram
(A "pyproject.toml" file was found, but editable mode currently requires a setup.py based build.)
WARNING: You are using pip version 20.0.2; however, version 22.1.2 is available.
You should consider upgrading via the '/Volumes/Code/ctid/tram/venv/bin/python3.9 -m pip install --upgrade pip' command.

(venv) $ pip install pip -U     
Collecting pip
  Downloading pip-22.1.2-py3-none-any.whl (2.1 MB)
     |████████████████████████████████| 2.1 MB 5.9 MB/s
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 20.0.2
    Uninstalling pip-20.0.2:
      Successfully uninstalled pip-20.0.2
Successfully installed pip-22.1.2

(venv) $ pip install -e .       
Obtaining file:///Volumes/Code/ctid/tram
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Installing collected packages: tram
  Attempting uninstall: tram
    Found existing installation: tram 1.2.0
    Uninstalling tram-1.2.0:
      Successfully uninstalled tram-1.2.0
  Running setup.py develop for tram
Successfully installed tram-1.2.0

Right, I install 22.1.2 and it works.
After that I have tried to execute step 7 and fails:

(venv3.9) javi@ubuntu:~/Desktop/TRAM 1.2.0/tram$ tram makemigrations tram
bash: /home/javi/Desktop/TRAM 1.2.0/tram/venv3.9/bin/tram: "/home/javi/Desktop/TRAM: bad interpreter: No such file or directory

Sounds like the virtualenv got corrupted at some point. Take a look at the first line of the tram script and verify it has a valid path to a python executable.

$ head $(which tram)
#!/Volumes/Code/ctid/tram/venv/bin/python3.9
# EASY-INSTALL-ENTRY-SCRIPT: 'tram','console_scripts','tram'
import re
import sys

# for compatibility with easy_install; see #2198
__requires__ = 'tram'

try:
    from importlib.metadata import distribution

If it's not pointing at a valid python executable, then try deleting the virtualenv and running through the steps again.

It's working!! Thank you very much, you have helped me a lot.