Hey I am using python script to create ".json" file and getting following error
Traceback (most recent call last):
File "ngs_rawdata_config_creator.py", line 104, in <module>
per_lib = parse_per_lib(pd.read_csv(args.per_lib_input, dtype=str))
File "ngs_rawdata_config_creator.py", line 32, in parse_per_lib
per_lib_dict['lib_paths'] = assign_libpaths(lib_basepaths)
File "ngs_rawdata_config_creator.py", line 53, in assign_libpaths
libpaths_dict[lib] = basepath_to_filepathsdict(path, "*.fastq.gz", ".*_L(\d+)_R(\d+).*\.fastq\.gz")
File "ngs_rawdata_config_creator.py", line 73, in basepath_to_filepathsdict
if rmatch.group(0) == basename:
AttributeError: 'NoneType' object has no attribute 'group
'
this is the part of the code
for fq in all_fastqs:
basename = os.path.basename(fq)
rmatch = re.match(capture_regex, basename)
if rmatch.group(0) == basename:
lane = rmatch.group(1)
read = rmatch.group(2)
readgroups[lane][read] = fq
If re.match doesn't get a match, it returns None. You need to check for that:
if rmatch and rmatch.group(0) == basename:
Related
My code is bellow and I am getting "'NoneType' object has no attribute 'group'" error what is the reason? (And sorry for my question form I am a newbie at this)
from PIL import Image
import pytesseract
import googletrans
from googletrans import Translator
translator = Translator()
pytesseract.pytesseract.tesseract_cmd = r"C:\\Program Files\\Tesseract-OCR\\tesseract.exe"
with open("emre.txt", mode = "w+") as f:
f.write(pytesseract.image_to_string("01-361.jpg"))
s = open("emre.txt", "r")
if s.mode == "r":
ceviri = s.read()
print(ceviri)
result = translator.translate(ceviri, src= "en", dest="tr")
with open("çeviri.txt", "w") as k:
k.write(result.text)
And my error is =
Traceback (most recent call last):
File "c:\Users\usr\amazon_py\çeviri.py", line 20, in <module>
result = translator.translate(ceviri, src= "en", dest="tr")
File "C:\Users\usr\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\googletrans\client.py", line 182, in translate
data = self._translate(text, dest, src, kwargs)
File "C:\Users\usr\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\googletrans\client.py", line 78, in _translate
token = self.token_acquirer.do(text)
File "C:\Users\usr\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\googletrans\gtoken.py", line 194, in do
self._update()
File "C:\Users\usr\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\googletrans\gtoken.py", line 62, in _update
code = self.RE_TKK.search(r.text).group(1).replace('var ', '')
AttributeError: 'NoneType' object has no attribute 'group'
after the google translate downgrade error =
File "c:\Users\usr\amazon_py\çeviri.py", line 20, in <module>
emre = translator.translate(ceviri, src= "en", dest="tr")
File "C:\Users\usr\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\googletrans\client.py", line 219, in translate
parsed = json.loads(data[0][2])
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\json\__init__.py", line 339, in loads
raise TypeError(f'the JSON object must be str, bytes or bytearray, '
TypeError: the JSON object must be str, bytes or bytearray, not NoneType
joke = pyjokes.get_joke() ## Get a joke.
translator = Translator() ## Initalize a Translator object.
print( translator.translate(joke, dest='hi').text)
Traceback (most recent call last): File "A.I.py", line 206, in <module>
print( translator.translate(joke, dest='hi').text) File "C:\Users\NEERAJ KUSHWAH\AppData\Local\Programs\Python\Python38\lib\site-packages\googletrans\client.py", line 182, in translate
data = self._translate(text, dest, src, kwargs) File "C:\Users\NEERAJ KUSHWAH\AppData\Local\Programs\Python\Python38\lib\site-packages\googletrans\client.py", line 78, in _translate
token = self.token_acquirer.do(text) File "C:\Users\NEERAJ KUSHWAH\AppData\Local\Programs\Python\Python38\lib\site-packages\googletrans\gtoken.py", line 194, in do
self._update() File "C:\Users\NEERAJ KUSHWAH\AppData\Local\Programs\Python\Python38\lib\site-packages\googletrans\gtoken.py", line 62, in _update
code = self.RE_TKK.search(r.text).group(1).replace('var ', '') AttributeError: 'NoneType' object has no attribute 'group'
I am building a Python Application that searches files with a given path and returns them.
This is the code:
def search(path):
name = 'filename'
files = os.listdir(path)
for filename in files:
fullname = os.path.join(path, filename)
if name in fullname and 'rat' not in fullname:
print(colored('[*] Found: '+fullname+' [*]','blue'))
return ''+fullname
elif os.path.isdir(fullname):
return search(fullname)
When i run this piece of code:
path = search('output/host/smali/')
code = 'invoke-super {p0, p1}, Lcom/example/rat/activity/MainActivity;->onCreate(Landroid/os/Bundle;)V'
into = 'invoke-static,onCreate'
print(path+' '+code+' '+into)
The Application launches this Exception:
Traceback (most recent call last):
File "./bane.py", line 48, in <module>
login(creds[0],creds[1])
File "./bane.py", line 16, in login
bane = baneshell(username)
File "/mnt/c/Users/stecco/Desktop/bane/baneshell.py", line 16, in __init__
self.start()
File "/mnt/c/Users/stecco/Desktop/bane/baneshell.py", line 36, in start
self.execute(command)
File "/mnt/c/Users/stecco/Desktop/bane/baneshell.py", line 26, in execute
rat.rat(self.username)
File "/mnt/c/Users/stecco/Desktop/bane/modules/rat/rat.py", line 13, in __init__
self.start()
File "/mnt/c/Users/stecco/Desktop/bane/modules/rat/rat.py", line 18, in start
self.execute(command)
File "/mnt/c/Users/stecco/Desktop/bane/modules/rat/rat.py", line 42, in execute
inject.inject(command.replace('inject',''),self.address,self.port)
File "/mnt/c/Users/stecco/Desktop/bane/modules/rat/rat_modules/injector.py", line 101, in inject
injectcode(address,port)
File "/mnt/c/Users/stecco/Desktop/bane/modules/rat/rat_modules/injector.py", line 75, in injectcode
print(path+' '+code+' '+into)
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
Update: the code is printing nothing in method search before returning the fullname variable
I am trying to train some data for a classification tool I am building. I have done some simple examples and it works fine.
I am now trying to use some data from work (which is what it will be used on), and I am getting a TypeError: 'float' object is not iterable error, the traceback is here:
Traceback (most recent call last):
File "C:/Users/nicholas/Desktop/machineTraining/classLearning.py", line 13, in <module>
cl = NaiveBayesClassifier(train)
File "C:\Users\nicholas\AppData\Local\Programs\Python\Python36-32\lib\site-packages\textblob\classifiers.py", line 205, in __init__
super(NLTKClassifier, self).__init__(train_set, feature_extractor, format, **kwargs)
File "C:\Users\nicholas\AppData\Local\Programs\Python\Python36-32\lib\site-packages\textblob\classifiers.py", line 139, in __init__
self._word_set = _get_words_from_dataset(self.train_set) #Keep a hidden set of unique words.
File "C:\Users\nicholas\AppData\Local\Programs\Python\Python36-32\lib\site-packages\textblob\classifiers.py", line 63, in _get_words_from_dataset
return set(all_words)
This is my code:
df = pd.read_csv("C:/Users/nicholas\Desktop/trainData.csv", encoding='latin-1')
df['train'] = df[['Summary', 'Primary Classification']].apply(tuple, axis=1)
aTrain = df['train'].values.tolist()
train = aTrain
cl = NaiveBayesClassifier(train)
Any ideas on what is going wrong?
I have an excel file with a ton of rows, and a column containing HZ, NZ or SZ now is this erroring out, and I have no idea on how to fix it.
region = ws.cell(row=srow, column=3)
if region.value == "HZ":
nregion = "Houston"
elif region.value == "NZ":
nregion = "North"
elif region.value == "SZ":
nregion = "South"
It errors with the following messages:
Traceback (most recent call last):
File "PowerExp.py", line 18, in <module>
wb=load_workbook(filename = wbfile)
File "/usr/local/lib/python2.7/dist-packages/openpyxl/reader/excel.py", line 136, in load_workbook
_load_workbook(wb, archive, filename, use_iterators, keep_vba)
File "/usr/local/lib/python2.7/dist-packages/openpyxl/reader/excel.py", line 171, in _load_workbook
style_table = read_style_table(archive.read(ARC_STYLE))
File "/usr/local/lib/python2.7/dist-packages/openpyxl/reader/style.py", line 42, in read_style_table
font_list = parse_fonts(root, xmlns, color_index)
File "/usr/local/lib/python2.7/dist-packages/openpyxl/reader/style.py", line 160, in parse_fonts
font.size = font_node.find(QName(xmlns, 'sz').text).get('val')
AttributeError: 'NoneType' object has no attribute 'get'
I can't change the value and save the workbook as it is automatically retrieved from the email server and loaded into MySQL.