Tag Archives: python

[Solved] Python-selenium locates an element cannot be clicked error: ElementClickInterceptedException

Problem Description:

prompt: elementclickinterceptedexception: Message: element click
when performing selenium UI automation test, you may encounter the situation that elements can be located but cannot be clicked. The following error is:

When writing an automatic program, you will encounter a new window pop-up, and the program always locates the element on the first window page by default. In this way, the element will not be located, and the program will report an error.

For example, when locating an element, the UI is covered by the pop-up window in the list. If an element cannot be located, the program reports an error
click the code of the located element:

web_driver.find_element(By.CSS_SELECTOR,'#funtype_click').click()

Cause analysis:

prompt: elementclickinterceptedexception
when locating an element, the UI is covered by the pop-up window in the list. If an element cannot be located, the element click has been blocked</ font>


Solution:

Error code:

# Click on the function category
web_driver.find_element(By.CSS_SELECTOR,'#funtype_click').click()

Resolved Code:

# Functional Category
funtype_click = web_driver.find_element(By.CSS_SELECTOR,'#funtype_click')
web_driver.execute_script('arguments[0].click()',funtype_click)

[Solved] python3.10 Error: cannot import name ‘Iterable‘ from ‘collections‘

Generally, errors will be reported when using the pyechards library for higher versions of Python:
cannot import name ‘iteratable’ from ‘collections’

Solution:
go to the directory where the pyecarts library is installed, enter the pyecarts file, open render, and continue to open engine Py file, where you can find the following code:

from collections import Iterable

Change to the following code:

from collections.abc import Iterable

Call through the following command, and no error will be reported again

from collections.abc import Iterable

Solve the error of panda index unalignable Boolean series provided as indexer

Complete error reports are as follows: pandas core.indexing.IndexingError: Unalignable boolean Series provided as indexer (index of the boolean Series and of the indexed object do not match).

Solution:

There are two indexing methods, one of which can be selected:

Solution 1

dataframe[pd.Series([True, True, True], index=dataframe.index)]

Solution 2:

dataframe.loc[pd.Series([True, True], index=['a', 'b']).index]

Problem analysis

An error will appear in the following code:

import pandas as pd
import numpy as np


dataframe = pd.DataFrame(data=np.random.random(size=(3, 5)), index=['a', 'b', 'c'])

Error codes are as follows:

dataframe[pd.Series([True, True], index=['a', 'b'])]

You can see that the original dataframe includes 3 lines, but there are only two true values here, so an error is reported. The correct method is:

dataframe[pd.Series([True, True, True], index=['a', 'b', 'c'])]
dataframe.loc[pd.Series([True, True], index=['a', 'b']).index]

python3 Execute except Exception, e Error [How to Solve]

During code execution, an error except timeoutexception is found. E:
the reasons are as follows:

This code is only available in python2 X is available, and python 3 no longer uses this method

Solution:
Switch the corresponding version to python2
Modify except Exception e: to except Exception as e:

How to Solve program install error 0x80070660

When installing Python and VC runtime library, the errors reported by many software are 0x80070660, saying that the temporary folder has no space or permission.

After detection, it is found that there is permission and space. Next solution

Solution:

Create the installer folder in the %windir% directory.

 

The following methods are from YouTube. I’ve tried them and they’re useless. They may be useful to others. Let’s put them here for the time being

Method 1: win10 system, run “troubleshooting” and restart

Method 2: run the following command and restart

net stop wuauserv
net stop cryptSvc
net stop bits
net stop msiserver
ren C:\Windows\SoftwareDistribution SoftwareDistribution.old
ren C:\Windows\System32\catroot2 catroot2.old
net start wuauserv
net start cryptSvc
net start bits
net start msiserver

Method 3: rmdir/S/Q C: \ windows \ softwaredistribution \ download \ sharedfilecache

Method 4: Windows Update – & gt; Advanced options} turn off the “provide additional Microsoft product updates when updating windows” option and restart

Method 5: install VC runtime library_ redist. x[Arch]. exe

[Solved] Python operate Kafka error: SyntaxError: invalid syntax

Python operation Kafka reports an error: return ‘& lt; SimpleProducer batch=%s>’ %self.async

return ‘< SimpleProducer batch=%s>’ % self. async
^^^^^
SyntaxError: invalid syntax

reason:

Because PY3 Async has become a keyword in 7. This leads to incompatibility.

Solution:

Method 1:

The latest Kafka version is used, but the Kafka on pypi has not been replaced with the latest one. You can upgrade Kafka Python using the following method
PIP install Kafka python

Method 2:

Just switch to version 3.6 and wait for subsequent upgrades

How to Solve jupyter notebook Read CSV files Error

import pandas as pd
df = pd.read_csv('Pokemon1.csv',index_col = 0)

An error is reported after executing the code: Unicode decodeerror: ‘UTF-8’ codec can’t decode byte 0x89 in position 1538: invalid start byte
an error is still reported when trying to manually specify the encoding format [encoding = “UTF-8″/encoding = “GBK”):

df = pd.read_csv('Pokemon1.csv',index_col = 0,encoding="gbk")

Solution:
1 Find the CSV file used -> Right mouse button -> Opening method -> Select Notepad
2 Open the file and select File -> “Save as”, you can see that the default code is ANSI. Select UTF-8 to save a copy again, and then open it with PD.Read_csv(). There will be no error:


[Solved] Runtime error: expected scalar type Float but found Double

Error: Runtime error: expected scalar type Float but found Double

w_true=torch.tensor([2,-3.4]).T
b_true=4.2
feature = torch.from_numpy(np.random.normal(0,1,(num_input,num_example)))
#feature = torch.float32(feature)
labels = torch.matmul(w_true.T,feature)+b_true

Problem: runtime error: expected scalar type float but found double
reason: NP random. The data generated by Rand() is float64, while torch defaults to float32, so the problem arises
solution

feature = torch.from_numpy(np.float32(np.random.normal(0,1,(num_input,num_example))))