theupdateframework / python-tuf

Python reference implementation of The Update Framework (TUF)
https://theupdateframework.com/
Apache License 2.0
1.62k stars 269 forks source link

ModuleNotFoundError: No module named 'tuf.conf' #845

Closed sreekang closed 5 years ago

sreekang commented 5 years ago

Description of issue: I am trying to deploy Uptane demo in Windows. No module found in the name of 'tuf.conf' When i execute $python -i demo/start_servers.py

Console Output: D:\Project\FOTA\workspace\uptane>python -i demo/start_servers.py Traceback (most recent call last): File "demo/start_servers.py", line 19, in <module> import demo File "d:\project\fota\workspace\uptane\demo\__init__.py", line 6, in <module> import uptane # Import before TUF modules; may change tuf.conf values. File "d:\project\fota\workspace\uptane\uptane\__init__.py", line 14, in <module> import tuf.conf ModuleNotFoundError: No module named 'tuf.conf'

awwad commented 5 years ago

It looks like you're trying to use the wrong TUF fork. Did you follow the installation instructions in the README?

pip install -r dev-requirements.txt should provide the appropriate TUF fork for Uptane for you.

awwad commented 5 years ago

With that said, I don't think that the demo/ code in Uptane is Windows compatible, though if it isn't, the issues would be minor ones. I don't think that's related to your error, but once you fix that, you might run into others.

sreekang commented 5 years ago

I have uninstalled the existing tuf. python -m pip uninstall tuf

Then, installed again with dev-requirement.txt

--editable git://github.com/awwad/tuf.git@develop#egg=tuf

python -m pip install -r dev-requirements.txt

Re-installed successfully.

Retried and Console Output Error msg as follows: D:\Project\FOTA\workspace\uptane>python -i demo/start_servers.py Warning: The repository and developer tools require additional libraries, which can be installed as follows: $ pip install tuf[tools] ←[45mImageRepo:←[0m Initializing repository Creating 'D:\\Project\\FOTA\\workspace\\uptane\\imagerepo' Creating 'D:\\Project\\FOTA\\workspace\\uptane\\imagerepo\\metadata.staged' Creating 'D:\\Project\\FOTA\\workspace\\uptane\\imagerepo\\targets' ←[45mImageRepo:←[0m Loading all keys Traceback (most recent call last): File "demo/start_servers.py", line 47, in <module> main() File "demo/start_servers.py", line 31, in main di.clean_slate() File "d:\project\fota\workspace\uptane\demo\demo_image_repo.py", line 94, in clean_slate key_root_pri = demo.import_private_key('mainroot') File "d:\project\fota\workspace\uptane\demo\__init__.py", line 96, in import_private_key os.path.join(DEMO_KEYS_DIR, keyname), password='pw') File "d:\project\fota\workspace\uptane\src\tuf\tuf\repository_lib.py", line 1175, in import_ed25519_privatekey_from_fi le key_object = tuf.keys.decrypt_key(encrypted_key, password) File "d:\project\fota\workspace\uptane\src\tuf\tuf\keys.py", line 1369, in decrypt_key check_crypto_libraries(['general']) File "d:\project\fota\workspace\uptane\src\tuf\tuf\keys.py", line 635, in check_crypto_libraries ' crypto library specified in "tuf.conf.GENERAL_CRYPTO_LIBRARY" could' tuf.UnsupportedLibraryError: The 'pycrypto' crypto library specified in "tuf.conf.GENERAL_CRYPTO_LIBRARY" could not be i mported.

awwad commented 5 years ago

Like the appropriate version of TUF, that library should also have been installed already if you ran python -m pip install -r dev-requirements.txt in the uptane directory.

awwad commented 5 years ago

This is not a TUF issue, so I'm going to close this. (The Uptane code doesn't use the code in this TUF repository.) Please email me or create an issue in the Uptane repository if you run into trouble with the Uptane demo. 🙂

sreekang commented 5 years ago

Referred to this Installation steps for tuf

D:\Project\FOTA\workspace\uptane>python -m pip uninstall tuf
Uninstalling tuf-0.10.0:
  Would remove:
    c:\programs\winpython64_3701\python-3.7.0.amd64\lib\site-packages\tuf.egg-link
Proceed (y/n)? y
  Successfully uninstalled tuf-0.10.0

D:\Project\FOTA\workspace\uptane>python -m pip install tuf
Collecting tuf
  Using cached https://files.pythonhosted.org/packages/79/ca/181576ead044b54c8ca364840bbec0c8ebb453495033df4bce2fb152f97
d/tuf-0.11.1-py2.py3-none-any.whl
Requirement already satisfied: six>=1.11.0 in c:\programs\winpython64_3701\python-3.7.0.amd64\lib\site-packages (from tu
f) (1.11.0)
Requirement already satisfied: iso8601>=0.1.12 in c:\programs\winpython64_3701\python-3.7.0.amd64\lib\site-packages (fro
m tuf) (0.1.12)
Requirement already satisfied: securesystemslib>=0.11.2 in c:\programs\winpython64_3701\python-3.7.0.amd64\lib\site-pack
ages (from tuf) (0.11.3)
Installing collected packages: tuf
Successfully installed tuf-0.11.1

D:\Project\FOTA\workspace\uptane>python -m pip install securesystemslib[crypto,pynacl]
Requirement already satisfied: securesystemslib[crypto,pynacl] in c:\programs\winpython64_3701\python-3.7.0.amd64\lib\si
te-packages (0.11.3)
Requirement already satisfied: six>=1.11.0 in c:\programs\winpython64_3701\python-3.7.0.amd64\lib\site-packages (from se
curesystemslib[crypto,pynacl]) (1.11.0)
Requirement already satisfied: cryptography>=2.2.2; extra == "crypto" in c:\programs\winpython64_3701\python-3.7.0.amd64
\lib\site-packages (from securesystemslib[crypto,pynacl]) (2.3)
Requirement already satisfied: colorama>=0.3.9; extra == "crypto" in c:\programs\winpython64_3701\python-3.7.0.amd64\lib
\site-packages (from securesystemslib[crypto,pynacl]) (0.3.9)
Requirement already satisfied: pynacl>1.2.0; extra == "pynacl" in c:\programs\winpython64_3701\python-3.7.0.amd64\lib\si
te-packages (from securesystemslib[crypto,pynacl]) (1.2.1)
Requirement already satisfied: idna>=2.1 in c:\programs\winpython64_3701\python-3.7.0.amd64\lib\site-packages (from cryp
tography>=2.2.2; extra == "crypto"->securesystemslib[crypto,pynacl]) (2.7)
Requirement already satisfied: asn1crypto>=0.21.0 in c:\programs\winpython64_3701\python-3.7.0.amd64\lib\site-packages (
from cryptography>=2.2.2; extra == "crypto"->securesystemslib[crypto,pynacl]) (0.24.0)
Requirement already satisfied: cffi!=1.11.3,>=1.7 in c:\programs\winpython64_3701\python-3.7.0.amd64\lib\site-packages (
from cryptography>=2.2.2; extra == "crypto"->securesystemslib[crypto,pynacl]) (1.11.5)
Requirement already satisfied: pycparser in c:\programs\winpython64_3701\python-3.7.0.amd64\lib\site-packages (from cffi
!=1.11.3,>=1.7->cryptography>=2.2.2; extra == "crypto"->securesystemslib[crypto,pynacl]) (2.17)

D:\Project\FOTA\workspace\uptane>python -m pip install -r dev-requirements.txt
Obtaining file:///D:/Project/FOTA/workspace/uptane (from -r dev-requirements.txt (line 8))
Requirement already satisfied: canonicaljson==1.1.4 in c:\programs\winpython64_3701\python-3.7.0.amd64\lib\site-packages
 (from -r dev-requirements.txt (line 1)) (1.1.4)
Requirement already satisfied: cffi==1.11.5 in c:\programs\winpython64_3701\python-3.7.0.amd64\lib\site-packages (from -
r dev-requirements.txt (line 2)) (1.11.5)
Requirement already satisfied: cryptography==2.3 in c:\programs\winpython64_3701\python-3.7.0.amd64\lib\site-packages (f
rom -r dev-requirements.txt (line 3)) (2.3)
Requirement already satisfied: pynacl==1.2.1 in c:\programs\winpython64_3701\python-3.7.0.amd64\lib\site-packages (from
-r dev-requirements.txt (line 4)) (1.2.1)
Requirement already satisfied: pyasn1==0.4.4 in c:\programs\winpython64_3701\python-3.7.0.amd64\lib\site-packages (from
-r dev-requirements.txt (line 5)) (0.4.4)
Requirement already satisfied: pycrypto==2.6.1 in c:\programs\winpython64_3701\python-3.7.0.amd64\lib\site-packages (fro
m -r dev-requirements.txt (line 6)) (2.6.1)
Obtaining tuf from git+git://github.com/awwad/tuf.git@develop#egg=tuf (from -r dev-requirements.txt (line 7))
  Updating d:\project\fota\workspace\uptane\src\tuf clone (to revision develop)
Requirement already satisfied: tox==3.1.2 in c:\programs\winpython64_3701\python-3.7.0.amd64\lib\site-packages (from -r
dev-requirements.txt (line 9)) (3.1.2)
Requirement already satisfied: iso8601 in c:\programs\winpython64_3701\python-3.7.0.amd64\lib\site-packages (from uptane
==0.1.0->-r dev-requirements.txt (line 8)) (0.1.12)
Requirement already satisfied: six in c:\programs\winpython64_3701\python-3.7.0.amd64\lib\site-packages (from uptane==0.
1.0->-r dev-requirements.txt (line 8)) (1.11.0)
Requirement already satisfied: frozendict>=1.0 in c:\programs\winpython64_3701\python-3.7.0.amd64\lib\site-packages (fro
m canonicaljson==1.1.4->-r dev-requirements.txt (line 1)) (1.2)
Requirement already satisfied: simplejson>=3.6.5 in c:\programs\winpython64_3701\python-3.7.0.amd64\lib\site-packages (f
rom canonicaljson==1.1.4->-r dev-requirements.txt (line 1)) (3.16.0)
Requirement already satisfied: pycparser in c:\programs\winpython64_3701\python-3.7.0.amd64\lib\site-packages (from cffi
==1.11.5->-r dev-requirements.txt (line 2)) (2.17)
Requirement already satisfied: asn1crypto>=0.21.0 in c:\programs\winpython64_3701\python-3.7.0.amd64\lib\site-packages (
from cryptography==2.3->-r dev-requirements.txt (line 3)) (0.24.0)
Requirement already satisfied: idna>=2.1 in c:\programs\winpython64_3701\python-3.7.0.amd64\lib\site-packages (from cryp
tography==2.3->-r dev-requirements.txt (line 3)) (2.7)
Requirement already satisfied: pluggy<1,>=0.3.0 in c:\programs\winpython64_3701\python-3.7.0.amd64\lib\site-packages (fr
om tox==3.1.2->-r dev-requirements.txt (line 9)) (0.6.0)
Requirement already satisfied: packaging>=17.1 in c:\programs\winpython64_3701\python-3.7.0.amd64\lib\site-packages (fro
m tox==3.1.2->-r dev-requirements.txt (line 9)) (17.1)
Requirement already satisfied: py<2,>=1.4.17 in c:\programs\winpython64_3701\python-3.7.0.amd64\lib\site-packages (from
tox==3.1.2->-r dev-requirements.txt (line 9)) (1.5.4)
Requirement already satisfied: virtualenv>=1.11.2 in c:\programs\winpython64_3701\python-3.7.0.amd64\lib\site-packages (
from tox==3.1.2->-r dev-requirements.txt (line 9)) (16.4.3)
Requirement already satisfied: pyparsing>=2.0.2 in c:\programs\winpython64_3701\python-3.7.0.amd64\lib\site-packages (fr
om packaging>=17.1->tox==3.1.2->-r dev-requirements.txt (line 9)) (2.2.0)
Installing collected packages: tuf, uptane
  Found existing installation: tuf 0.11.1
    Uninstalling tuf-0.11.1:
      Successfully uninstalled tuf-0.11.1
  Running setup.py develop for tuf
  Found existing installation: uptane 0.1.0
    Uninstalling uptane-0.1.0:
      Successfully uninstalled uptane-0.1.0
  Running setup.py develop for uptane
Successfully installed tuf uptane

D:\Project\FOTA\workspace\uptane>python -i demo/start_servers.py
Warning: The repository and developer tools require additional libraries, which can be installed as follows:
 $ pip install tuf[tools]
←[45mImageRepo:←[0m Initializing repository
Creating 'D:\\Project\\FOTA\\workspace\\uptane\\imagerepo'
Creating 'D:\\Project\\FOTA\\workspace\\uptane\\imagerepo\\metadata.staged'
Creating 'D:\\Project\\FOTA\\workspace\\uptane\\imagerepo\\targets'
←[45mImageRepo:←[0m Loading all keys
Traceback (most recent call last):
  File "demo/start_servers.py", line 47, in <module>
    main()
  File "demo/start_servers.py", line 31, in main
    di.clean_slate()
  File "d:\project\fota\workspace\uptane\demo\demo_image_repo.py", line 94, in clean_slate
    key_root_pri = demo.import_private_key('mainroot')
  File "d:\project\fota\workspace\uptane\demo\__init__.py", line 96, in import_private_key
    os.path.join(DEMO_KEYS_DIR, keyname), password='pw')
  File "d:\project\fota\workspace\uptane\src\tuf\tuf\repository_lib.py", line 1175, in import_ed25519_privatekey_from_fi
le
    key_object = tuf.keys.decrypt_key(encrypted_key, password)
  File "d:\project\fota\workspace\uptane\src\tuf\tuf\keys.py", line 1369, in decrypt_key
    check_crypto_libraries(['general'])
  File "d:\project\fota\workspace\uptane\src\tuf\tuf\keys.py", line 635, in check_crypto_libraries
    ' crypto library specified in "tuf.conf.GENERAL_CRYPTO_LIBRARY" could'
tuf.UnsupportedLibraryError: The 'pycrypto' crypto library specified in "tuf.conf.GENERAL_CRYPTO_LIBRARY" could not be imported.
awwad commented 5 years ago

@sreekang If your intention is to work on Uptane, please stick to the Uptane instructions. The libraries you're installing there are not the right libraries to use with Uptane. Uptane does not currently use theupdateframework/tuf or securesystemslib; Uptane currently uses a fork of TUF at awwad/tuf. Uninstall them all and follow only the Uptane instructions.

The only pip command that should be necessary is the one provided in the Uptane instructions: in the Uptane repository (not in a clone of theupdateframework/tuf): pip install -r dev-requirements.txt (or python -m pip install -r dev-requirements.txt)

Let me know if you run into issues doing that.

awwad commented 5 years ago

Does that clear things up? If you need to chat on the phone / Google hangouts / etc to clear things up further, let me know.

sreekang commented 5 years ago

@awwad, I do not have your contact details. I have restarted from scratch. I am getting issues. I have created a new issue Porting Demo in Windows | Dependencies installation issue in Uptane project.