I have installed bandit with pip but when I run bandit --help in the command line, I get the following error:
Traceback (most recent call last):
File "/home/alipqb/.local/share/virtualenvs/django_with_pytest-FUuC6zdm/bin/bandit", line 5, in <module>
from bandit.cli.main import main
File "/home/alipqb/.local/share/virtualenvs/django_with_pytest-FUuC6zdm/lib/python3.8/site-packages/bandit/__init__.py", line 19, in <module>
from bandit.core import config # noqa
File "/home/alipqb/.local/share/virtualenvs/django_with_pytest-FUuC6zdm/lib/python3.8/site-packages/bandit/core/__init__.py", line 17, in <module>
from bandit.core import config # noqa
File "/home/alipqb/.local/share/virtualenvs/django_with_pytest-FUuC6zdm/lib/python3.8/site-packages/bandit/core/config.py", line 12, in <module>
from bandit.core import extension_loader
File "/home/alipqb/.local/share/virtualenvs/django_with_pytest-FUuC6zdm/lib/python3.8/site-packages/bandit/core/extension_loader.py", line 109, in <module>
MANAGER = Manager()
File "/home/alipqb/.local/share/virtualenvs/django_with_pytest-FUuC6zdm/lib/python3.8/site-packages/bandit/core/extension_loader.py", line 27, in __init__
self.load_blacklists(blacklists_namespace)
File "/home/alipqb/.local/share/virtualenvs/django_with_pytest-FUuC6zdm/lib/python3.8/site-packages/bandit/core/extension_loader.py", line 78, in load_blacklists
for val in six.itervalues(self.blacklist):
AttributeError: module 'six' has no attribute 'itervalues'
Also I should mention that bandit is in the path and there is no problem with it.
What should I do?
Related
I am trying to run the following code: https://github.com/silviazuffi/smalst. However, I am using Python 3 instead of Python 2 because it does not seem to be possible to use Python 2 anymore with new CUDA drivers and due to the compatibility issues of some libraries used by that repo.
However, I am getting this error:
AttributeError: module 'typing_extensions' has no attribute 'Protocol'
Full traceback:
Traceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.8/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/home/iegorval/Diploma/smalst/smal_eval.py", line 21, in <module>
from .nnutils import smal_predictor as pred_util
File "/home/iegorval/Diploma/smalst/nnutils/smal_predictor.py", line 22, in <module>
from ..nnutils.nmr import NeuralRenderer
File "/home/iegorval/Diploma/smalst/nnutils/nmr.py", line 9, in <module>
import chainer
File "/home/iegorval/Diploma/smalst/venv_smallst/lib/python3.8/site-packages/chainer/__init__.py", line 10, in <module>
from chainer import backends # NOQA
File "/home/iegorval/Diploma/smalst/venv_smallst/lib/python3.8/site-packages/chainer/backends/__init__.py", line 1, in <module>
from chainer.backends import cuda # NOQA
File "/home/iegorval/Diploma/smalst/venv_smallst/lib/python3.8/site-packages/chainer/backends/cuda.py", line 46, in <module>
from chainer.backends import intel64
File "/home/iegorval/Diploma/smalst/venv_smallst/lib/python3.8/site-packages/chainer/backends/intel64.py", line 8, in <module>
from chainer.configuration import config
File "/home/iegorval/Diploma/smalst/venv_smallst/lib/python3.8/site-packages/chainer/configuration.py", line 5, in <module>
from chainer import types # NOQA
File "/home/iegorval/Diploma/smalst/venv_smallst/lib/python3.8/site-packages/chainer/types.py", line 47, in <module>
class AbstractInitializer(tpe.Protocol):
AttributeError: module 'typing_extensions' has no attribute 'Protocol'
So, it fails to detect Protocol in the typing_extensions module. However, I have installed typing-extensions==3.7.4.3 (https://pypi.org/project/typing-extensions/), and PyPi description seem to state that Protocol should be there.
Any idea how to fix this error?
I am importing pytest in a file and I am getting an AttributeError.
The error is:
AttributeError: 'WindowsPath' object has no attribute 'read_text'
>>> import pytest
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "--\AppData\Local\Programs\Python\Python36\Lib\site-packages\pytest.py", line 6, in <module>
from _pytest.assertion import register_assert_rewrite
File "--\AppData\Local\Programs\Python\Python36\Lib\site-packages\_pytest\assertion\__init__.py", line 7, in <module>
from _pytest.assertion import rewrite
File "--\AppData\Local\Programs\Python\Python36\Lib\site-packages\_pytest\assertion\rewrite.py", line 26, in <module>
from _pytest.assertion import util
File "--\AppData\Local\Programs\Python\Python36\Lib\site-packages\_pytest\assertion\util.py", line 8, in <module>
import _pytest._code
File "--\AppData\Local\Programs\Python\Python36\Lib\site-packages\_pytest\_code\__init__.py", line 2, in <module>
from .code import Code # noqa
File "--\AppData\Local\Programs\Python\Python36\Lib\site-packages\_pytest\_code\code.py", line 24, in <module>
import pluggy
File "--\AppData\Local\Programs\Python\Python36\Lib\site-packages\pluggy\__init__.py", line 16, in <module>
from .manager import PluginManager, PluginValidationError
File "--\AppData\Local\Programs\Python\Python36\Lib\site-packages\pluggy\manager.py", line 11, in <module>
import importlib_metadata
File "--\AppData\Local\Programs\Python\Python36\Lib\site-packages\importlib_metadata\__init__.py", line 547, in <module>
__version__ = version(__name__)
File "--\AppData\Local\Programs\Python\Python36\Lib\site-packages\importlib_metadata\__init__.py", line 509, in version
return distribution(distribution_name).version
File "--\AppData\Local\Programs\Python\Python36\Lib\site-packages\importlib_metadata\__init__.py", line 260, in version
return self.metadata['Version']
File "--\AppData\Local\Programs\Python\Python36\Lib\site-packages\importlib_metadata\__init__.py", line 248, in metadata
self.read_text('METADATA')
File "--\AppData\Local\Programs\Python\Python36\Lib\site-packages\importlib_metadata\__init__.py", line 469, in read_text
return self._path.joinpath(filename).read_text(encoding='utf-8')
AttributeError: 'WindowsPath' object has no attribute 'read_text'
Is there a way how I can use pytest on my machine?
I have a windows machine.
Python version - 3.6.0
Pytest version - 5.2.4
Thanks
The issue I run into in Python2 was that pathlib is a module that was written for Python3 and althought there is a porting for Python 2.7, the porting (1.0.1) is missing the read_text() method.
In your log read_text() is being called from a string, that is the result of the joinpath(), and read_text() is not a method or attribute of a string. That was the whole purpose of pathlib
I am trying to run one git repo on Google cloud. But the system could not find the library path.
myname#cloudshell:~/text-to-text-transfer-transformer (lastproject-258210)$ python3 -c "import t5; print(t5.data.MixtureRegistry.names())"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/myname/text-to-text-transfer-transformer/t5/__init__.py", line 17, in <module>
import t5.data
File "/home/name/text-to-text-transfer-transformer/t5/data/__init__.py", line 17, in <module>
import t5.data.mixtures
File "/home/myname/text-to-text-transfer-transformer/t5/data/mixtures.py", line 26, in <module>
import t5.data.tasks # pylint: disable=unused-import
File "/home/myname/text-to-text-transfer-transformer/t5/data/tasks.py", line 25, in <module>
from t5.data.utils import set_global_cache_dirs
File "/home/myname/text-to-text-transfer-transformer/t5/data/utils.py", line 32, in <module>
from t5.data import sentencepiece_vocabulary
File "/home/myname/text-to-text-transfer-transformer/t5/data/sentencepiece_vocabulary.py", line 23, in <module>
import tensorflow_text as tf_text
File "/usr/local/lib/python3.7/site-packages/tensorflow_text-1.15.0rc0-py3.7-linux-x86_64.egg/tensorflow_text/__init__.py", line 21, in <module>
from tensorflow_text.python import metrics
File "/usr/local/lib/python3.7/site-packages/tensorflow_text-1.15.0rc0-py3.7-linux-x86_64.egg/tensorflow_text/python/metrics/__init__.py", line 20, in <module>
from tensorflow_text.python.metrics.text_similarity_metric_ops import *
File "/usr/local/lib/python3.7/site-packages/tensorflow_text-1.15.0rc0-py3.7-linux-x86_64.egg/tensorflow_text/python/metrics/text_similarity_metric_ops.py", line 28, in <module>
gen_text_similarity_metric_ops = load_library.load_op_library(resource_loader.get_path_to_datafile('_text_similarity_metric_ops.so'))
File "/usr/local/lib/python3.7/site-packages/tensorflow_core/python/framework/load_library.py", line 61, in load_op_library
lib_handle = py_tf.TF_LoadLibrary(library_filename)
tensorflow.python.framework.errors_impl.NotFoundError: libtensorflow_framework.so.1: cannot open shared object file: No such file or directory
I tried to print out the location of the libtensorflow:
myname#cloudshell:~/text-to-text-transfer-transformer (lastproject-258210)$ python3 -c 'import tensorflow as tf; print(tf.sysconfig.get_lib())'
/usr/local/lib/python3.7/site-packages/tensorflow_core
The question is how could I change the path so the system will find the path.Thanks for your help in advance!
You should be using the tensorflow-text version specified in the pip package (1.15rc0), which matches tensorflow 1.15.0. Are you manually installing a different version?
I am trying to install robot framework on my windows 10 machine but I am getting below error.
C:\WINDOWS\system32>pip install robotframework
Traceback (most recent call last):
File "C:\Python27\Scripts\pip-script.py", line 5, in <module>
from pkg_resources import load_entry_point
File "build\bdist.win32\egg\pkg_resources\__init__.py", line 36, in <module>
File "C:\Python27\lib\email\parser.py", line 12, in <module>
from email.feedparser import FeedParser
File "C:\Python27\lib\email\feedparser.py", line 27, in <module>
from email import message
File "C:\Python27\lib\email\message.py", line 16, in <module>
import email.charset
File "C:\Python27\lib\email\charset.py", line 13, in <module>
import email.base64mimeenter code here
File "C:\Python27\lib\email\base64mime.py", line 40, in <module>
from email.utils import fix_eols
File "C:\Python27\lib\email\utils.py", line 32, in <module>
from email._parseaddr import quote
File "C:\Python27\lib\email\_parseaddr.py", line 16, in <module>
import time, calendar
File "C:\Python27\Scripts\calendar.py", line 9, in <module>
cal=calendar.month(str(year),str(month))
TypeError: 'int' object is not callable
I have installed python 2.7.14 before starting robot framework installation.
Kindly suggest a way forward.
The version I used is python2.7, error occurs when I used script, but it works in command line.
from twisted.internet import protocol, reactor
and the errors:
ravjqpejcnngpig.eqo/re/fgh/ocr
Traceback (most recent call last):
File "./tsTclntTW.py", line 5, in <module>
from twisted.internet import protocol, reactor
File "/usr/local/lib/python2.7/dist-packages/twisted/__init__.py", line 18, in <module>
from zope.interface import Interface
File "/usr/local/lib/python2.7/dist-packages/zope.interface-4.0.1-py2.7-linux-x86_64.egg/zope/__init__.py", line 3, in <module>
import pkg_resources
File "/usr/local/lib/python2.7/dist-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 698, in <module>
self.callbacks.append(callback)
File "/usr/local/lib/python2.7/dist-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 701, in Environment
File "/usr/local/lib/python2.7/dist-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 96, in get_supported_platform
distutils.util.get_platform() normally reports the minimum version
File "/usr/local/lib/python2.7/dist-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 222, in get_build_platform
# fallback for MacPorts
File "/usr/lib/python2.7/distutils/util.py", line 65, in get_platform
osname = string.lower(osname)
AttributeError: 'module' object has no attribute 'lower'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/apport_python_hook.py", line 64, in apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
File "/usr/lib/python2.7/dist-packages/apport/__init__.py", line 1, in <module>
from apport.report import Report
File "/usr/lib/python2.7/dist-packages/apport/report.py", line 18, in <module>
import problem_report
File "/usr/lib/python2.7/dist-packages/problem_report.py", line 16, in <module>
from email.mime.multipart import MIMEMultipart
File "/usr/lib/python2.7/email/mime/multipart.py", line 9, in <module>
from email.mime.base import MIMEBase
File "/usr/lib/python2.7/email/mime/base.py", line 9, in <module>
from email import message
File "/usr/lib/python2.7/email/message.py", line 16, in <module>
import email.charset
File "/usr/lib/python2.7/email/charset.py", line 14, in <module>
import email.quoprimime
File "/usr/lib/python2.7/email/quoprimime.py", line 48, in <module>
from string import hexdigits
ImportError: cannot import name hexdigits
Original exception was:
Traceback (most recent call last):
File "./tsTclntTW.py", line 5, in <module>
from twisted.internet import protocol, reactor
File "/usr/local/lib/python2.7/dist-packages/twisted/__init__.py", line 18, in <module>
from zope.interface import Interface
File "/usr/local/lib/python2.7/dist-packages/zope.interface-4.0.1-py2.7-linux-x86_64.egg/zope/__init__.py", line 3, in <module>
import pkg_resources
File "/usr/local/lib/python2.7/dist-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 698, in <module>
self.callbacks.append(callback)
File "/usr/local/lib/python2.7/dist-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 701, in Environment
File "/usr/local/lib/python2.7/dist-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 96, in get_supported_platform
distutils.util.get_platform() normally reports the minimum version
File "/usr/local/lib/python2.7/dist-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 222, in get_build_platform
# fallback for MacPorts
File "/usr/lib/python2.7/distutils/util.py", line 65, in get_platform
osname = string.lower(osname)
AttributeError: 'module' object has no attribute 'lower'
I have re-installed the Python I used and it doesn't work, I'm in Ubuntu 12.04. Also I have do
grep ravjqpejcnngpig.eqo/re/fgh/ocr . -R -n
under /usr/lib/python2.7 but nothing returned.
Perhaps you have a module named string in your project, and it shadows the library module of the same name.
EDIT: To find out, add this to your script just before the failing import statement:
import string
print string.__file__