Tag Archives: python

UTF-8 encoding error when starting robotframework ride

Record the error when starting the robot framework ride

start-up ride.py The following error occurred

D:\Program Files(x86)\python\Scripts>python ride.py
Traceback (most recent call last):
  File “D:\Program Files(x86)\python\lib\site-packages\robotide\application\ application.py “, line 70, in OnInit
    self._ find_ robot_ installation()
  File “D:\Program Files(x86)\python\lib\site-packages\robotide\application\ application.py “, line 124, in _ find_ robot_ installation
    str( os.path.dirname (rf_ file), ‘utf-8’))).publish()
UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xa3 in position 20: invalid start byte
OnInit returned false, exiting…
Error in atexit._ run_ exitfuncs:
wx._ core.wxAssertionError : C++ assertion “GetEventHandler() == this” failed at ..\..\src\common\ wincmn.cpp (478) in wxWindowBase::~wxWindowBase(): any pushed event handlers must have been removed

 

 

Check the log. UTF-8 can’t encode 20,

Therefore, we tried the next step application.py The UTF-8 coding form in the file is changed to “GBK”, restart ride.py After that, ride is turned on

Warning when using numpy: runtimewarning: numpy.dtype size changed, may indicate binary incompatibility

You may encounter the following warnings when running Python programs after a new numpy installation:

/usr/local/lib/python2.7/dist-packages/scipy/linalg/basic.py:17: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88
  from ._solve_toeplitz import levinson
/usr/local/lib/python2.7/dist-packages/scipy/linalg/__init__.py:207: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88
  from ._decomp_update import *
/usr/local/lib/python2.7/dist-packages/scipy/special/__init__.py:640: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88
  from ._ufuncs import *
/usr/local/lib/python2.7/dist-packages/scipy/special/_ellip_harm.py:7: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88
  from ._ellip_harm_2 import _ellipsoid, _ellipsoid_norm
/usr/local/lib/python2.7/dist-packages/scipy/interpolate/_bsplines.py:10: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88
  from . import _bspl
/usr/local/lib/python2.7/dist-packages/scipy/sparse/lil.py:19: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88
  from . import _csparsetools
/usr/local/lib/python2.7/dist-packages/scipy/sparse/csgraph/__init__.py:165: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88
  from ._shortest_path import shortest_path, floyd_warshall, dijkstra,\
/usr/local/lib/python2.7/dist-packages/scipy/sparse/csgraph/_validation.py:5: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88
  from ._tools import csgraph_to_dense, csgraph_from_dense,\
/usr/local/lib/python2.7/dist-packages/scipy/sparse/csgraph/__init__.py:167: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88
  from ._traversal import breadth_first_order, depth_first_order, \
/usr/local/lib/python2.7/dist-packages/scipy/sparse/csgraph/__init__.py:169: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88
  from ._min_spanning_tree import minimum_spanning_tree
/usr/local/lib/python2.7/dist-packages/scipy/sparse/csgraph/__init__.py:170: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88
  from ._reordering import reverse_cuthill_mckee, maximum_bipartite_matching, \
/usr/local/lib/python2.7/dist-packages/scipy/spatial/__init__.py:95: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88
  from .ckdtree import *
/usr/local/lib/python2.7/dist-packages/scipy/spatial/__init__.py:96: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88
  from .qhull import *
/usr/local/lib/python2.7/dist-packages/scipy/spatial/_spherical_voronoi.py:18: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88
  from . import _voronoi
/usr/local/lib/python2.7/dist-packages/scipy/spatial/distance.py:122: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88
  from . import _hausdorff

At this point, you can check the version of numpy below

python
>>> import numpy
>>> numpy.__version__

If version 1.15.0 or above is displayed, the warning is caused by too high numpy version. Downgrade numpy version, such as 1.14.5

sudo pip uninstall numpy
sudo pip install numpy==1.14.5

Coursera Using python to access Web data quiz 4

 
 

1

point

1。

Which of the following Python data structures is most similar to the value returned in this line of Python:

 

1

*

*

*

*

List available video modes. If resolution is given show only modes matching it.x

= urllib.request.urlopen (

‘ http://data.pr4e.org/romeo.txt ‘)

*

*

*

*

socket

regular expression

-ise suffixes and with accents

file handle

list

1

point

2.

In this Python code, which line actually reads the data?

 

1

2

3

4

5

6

7

8

9

10

11

12

13

 

 

 

import socket

 

mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

mysock.connect((‘data.pr4e.org’, 80))

cmd = ‘GET http://data.pr4e.org/romeo.txt HTTP/1.0\n\n’.encode()

mysock.send(cmd)

 

while True:

data = mysock.recv(512)

if (len(data) < 1):

break

print(data.decode())

mysock.close()

 

 

 

 

mysock.recv()

socket.socket()

mysock.close()

mysock.connect()

mysock.send()

1

point

3。

Which of the following regular expressions would extract the URL from this line of HTML:

 

one

 

 

 

&lt;

P

&gt Please click;

&lt;

a

href

=

the United Nations http://www.dr-chuck.com/ the United Nations

&gt here;

&lt/

a

&gt;

&lt/

P

&gt;

 

 

 

 

href=)+”。

href=”

http:/ *

&lt.&gt;

one

point

4。

In this Python code,which line is most like the open)call to read a file:

 

1

2

3

4

5

6

7

8

9

10

11

12

13

 

 

 

 

import socket

 

mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

mysock.connect((‘data.pr4e.org’, 80))

cmd = ‘GET http://data.pr4e.org/romeo.txt HTTP/1.0\n\n’.encode()

mysock.send(cmd)

 

while True:

data = mysock.recv(512)

if (len(data) < 1):

break

print(data.decode())

mysock.close()

 

 

 

 

mysock.connect()

import socket

mysock.recv()

mysock.send()

socket.socket()

1

point

5。

Which HTTP header tells the browser the kind of document that is being returned?

HTML-Document:

Content-Type:

Document-Type:

ETag:

Metadata:

1

point

6。

What should you check before scraping a web site?

That the web site returns HTML for all pages

That the web site supports the HTTP GET command

That the web site allows scraping

That the web site only has links within the same site

1

point

7。

What is the purpose of the BeautifulSoup Python library?

It builds word clouds from web pages

It allows a web site to choose an attractive skin

It optimizes files that are retrieved many times

It animates web operations to make them more attractive

It repairs and parses HTML to make it easier for a program to understand

1

point

8。

What ends up in the “x” variable in the following code:

 

1

2

3

 

 

 

 

 

 

html
= urllib.request.urlopen(url).read()

soup
= BeautifulSoup(html,
‘html.parser’)

x
= soup(
‘a’)

 

 

 

 

A list of all the anchor tags (<a..) in the HTML from the URL

True if there were any anchor tags in the HTML from the URL

All of the externally linked CSS files in the HTML from the URL

All of the paragraphs of the HTML from the URL

1

point

9。

What is the most common Unicode encoding when moving data between systems?

UTF-32

UTF-64

UTF-16

UTF-128

UTF-8

1

point

10。

What is the decimal (Base-10) numeric value for the upper case letter “G” in the ASCII character set?

71

7

103

25073

14

1

point

11。

What word does the following sequence of numbers represent in ASCII:
108, 105, 110, 101
 

lost

tree

ping

line

func

1

point

12。

How are strings stored internally in Python 3?

Byte Code

UTF-8

ASCII

EBCDIC

Unicode

1

point

13。

When reading data across the network (i.e. from a URL) in Python 3, what method must be used to convert it to the internal format used by strings?

decode()

upper()

find()

trim()

encode()

1

point

1。

Which of the following Python data structures is most similar to the value returned in this line of Python:

 

1

*

*

*

*

x = urllib.request.urlopen (‘ http://data.pr4e.org/romeo.txt ‘)

*

*

*

*

socket

regular expression

-ise suffixes and with accents

file handle

list

1

point

2.

In this Python code, which line actually reads the data?

 

1

2

3

4

5

6

7

8

9

10

11

12

13

 

 

 

import socket

 

mysock
= socket.socket(socket.AF_INET, socket.SOCK_STREAM)

mysock.connect((
‘data.pr4e.org’,
80))

cmd
=
‘GET http://data.pr4e.org/romeo.txt HTTP/1.0
\n\n
‘.encode()

mysock.send(cmd)

 

while
True:

data
= mysock.recv(
512)

if (
len(data)
<
1):

break

print(data.decode())

mysock.close()

 

 

 

 

mysock.recv()

socket.socket()

mysock.close()

mysock.connect()

mysock.send()

1

point

3。

Which of the following regular expressions would extract the URL from this line of HTML:

 

one

 

 

 

&lt p&gt Please click&lt; http://www.dr-chuck.com/ “&gt here&lt

 

 

 

 

href=)+”。

href=”

http:/ *

&lt.&gt;

one

point

4。

In this Python code,which line is most like the open)call to read a file:

 

1

2

3

4

5

6

7

8

9

10

11

12

13

 

 

 

 

import socket

 

mysock
= socket.socket(socket.AF_INET, socket.SOCK_STREAM)

mysock.connect((
‘data.pr4e.org’,
80))

cmd
=
‘GET http://data.pr4e.org/romeo.txt HTTP/1.0
\n\n
‘.encode()

mysock.send(cmd)

 

while
True:

data
= mysock.recv(
512)

if (
len(data)
<
1):

break

print(data.decode())

mysock.close()

 

 

 

 

mysock.connect()

import socket

mysock.recv()

mysock.send()

socket.socket()

1

point

5。

Which HTTP header tells the browser the kind of document that is being returned?

HTML-Document:

Content-Type:

Document-Type:

ETag:

Metadata:

1

point

6。

What should you check before scraping a web site?

That the web site returns HTML for all pages

That the web site supports the HTTP GET command

That the web site allows scraping

That the web site only has links within the same site

1

point

7。

What is the purpose of the BeautifulSoup Python library?

It builds word clouds from web pages

It allows a web site to choose an attractive skin

It optimizes files that are retrieved many times

It animates web operations to make them more attractive

It repairs and parses HTML to make it easier for a program to understand

1

point

8。

What ends up in the “x” variable in the following code:

 

1

2

3

 

 

 

 

 

 

html = urllib.request.urlopen(url).read()

soup = BeautifulSoup(html, ‘html.parser’)

x = soup(‘a’)

 

 

 

 

A list of all the anchor tags (<a..) in the HTML from the URL

True if there were any anchor tags in the HTML from the URL

All of the externally linked CSS files in the HTML from the URL

All of the paragraphs of the HTML from the URL

1

point

9。

What is the most common Unicode encoding when moving data between systems?

UTF-32

UTF-64

UTF-16

UTF-128

UTF-8

1

point

10。

What is the decimal (Base-10) numeric value for the upper case letter “G” in the ASCII character set?

71

7

103

25073

14

1

point

11。

What word does the following sequence of numbers represent in ASCII:
108, 105, 110, 101
 

lost

tree

ping

line

func

1

point

12。

How are strings stored internally in Python 3?

Byte Code

UTF-8

ASCII

EBCDIC

Unicode

1

point

13。

When reading data across the network (i.e. from a URL) in Python 3, what method must be used to convert it to the internal format used by strings?

decode()

upper()

find()

trim()

encode()

 

 

Python about typeerror: required argument ‘mat’ (POS 2) not found error resolution

This error prompt means that the required parameter is not found, that is, the function in the code is missing the necessary parameter. Here’s an example of displaying a picture

import cv2
img = cv2.imread('./data/wiki.png')
cv2.imshow(img)
cv2.waitKey(0)

The following error occurs at runtime:

Traceback (most recent call last):
  File “D:/python_ opencv/ ss.py “, line 3, in <module>
    cv2.imshow(img)
TypeError: Required argument ‘mat’ (pos 2) not found

Process finished with exit code 1

A closer inspection shows that there are two necessary parameters from the CV2. Imshow() function, and another parameter is the name of the image window. The results are as follows

import cv2
img = cv2.imread('./data/wiki.png')
cv2.imshow('img',img)
cv2.waitKey(0)

Lingerror last 2 dimensions of the array must be square

Lingerror last 2 dimensions of the array must be square

reason

Because numpy uses X directly= numpy.linalg.solve (a, b) we must make sure that a is a square matrix, but my matrix is not a square matrix

solve

The least square method: C= np.linalg.lstsq (A, B, rcond=None)[0]

problem

It seems to be an equation with infinite solutions, and I don’t know how to output a unique solution in a specific range

Python TypeError: return arrays must be of ArrayType

from numpy import *
np.log(1.1, 2)

The above code will appear at run time

Typeerror: return arrays must be of arraytype, because the second parameter of log is not base but out array. If you just want to perform normal log operations, you can choose to use numpy.math.log (1.1, 2) or use the log function of Python’s math module

TypeError: Required argument ‘mat‘ (pos 2) not found

Traceback (most recent call last):
  File "/Users/*******/*****.py", line 225, in <module>
    cv2.imshow(r_image)
TypeError: Required argument 'mat' (pos 2) not found

This error prompt means that the required parameter is not found, that is, the function in the code is missing the necessary parameter.

cv2.imshow()

There should be two parameters: one is the name of the image window, namely title, and the other is the pixel value matrix of the displayed image.
In addition, the data type of the matrix is np.uint8 , floating point type will display exception.
Error will be reported:

TypeError: img is not a numpy array, neither a scalar

Solution:
transform the data type

image = numpy.array(image)

Python selenium — webriver cheat sheet

Recently, I saw a webriver cheat sheet on axatrikx, which is only made in Java. I thought I could organize a python version, and I got this blog post. The main methods and key points in webriver are sorted into a table for easy reference.

Webdriver Cheat Sheet

If it helps you, or if you have any good suggestions, please let me know.

Pdf version can be downloaded here


For more articles on Python selenium, please pay attention to my CSDN column: Python selenium automated test details

Module ‘Seaborn’ has no attribute ‘scatterplot’ solution

First, Seaborn contains the scatterplot module. However, running the corresponding sentence without syntax error will report an error, because the current Seaborn version is 0.8 or below.

Examples of errors are as follows:

Solution: upgrade Seaborn version! The corresponding statement is: PIP install Seaborn = = number of corresponding versions, for example: PIP install Seaborn = = 0.9.0

Rerun the statement to draw a normal diagram

During this period, CMD may require upgrading, and run for many times: Python – M PIP install — upgrade PIP may be invalid

Error, feedback similar permission problems, specific debugging methods can refer to the following:

https://blog.csdn.net/weixin_ 43870646/article/details/90020874

If: no module named pip.basecommand

It is suggested that you can uninstall the old version and re install the new version. The corresponding steps are as follows. Or you can refer to the author’s method https://blog.csdn.net/GuaPiQ/article/details/100593848

After reloading pip, you can upgrade Seaborn according to the first step above.

How to install CONDA can refer to this article: https://www.jianshu.com/p/edaa744ea47d