Category Archives: How to Fix

How to Fix Error in python3 | PIP install Dlib

Error in python3 PIP install Dlib:

Dlib has been installed before. It takes a long time. When you re install it, you forget some necessary conditions. This time, please make a note.

The error information is as follows:

Collecting dlib
  Downloading https://files.pythonhosted.org/packages/05/57/e8a8caa3c89a27f80bc78da39c423e2553f482a3705adc619176a3a24b36/dlib-19.17.0.tar.gz (3.4MB)
     |████████████████████████████████| 3.4MB 14kB/s
Building wheels for collected packages: dlib
  Building wheel for dlib (setup.py) ... error
  ERROR: Complete output from command 'f:\python36\python.exe' -u -c 'import setuptools, tokenize;__file__='"'"'C:\\Users\\fu\\AppData\\Local\\Temp\\pip-install-t50q34ym\\dlib\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\fu\AppData\Local\Temp\pip-wheel-g2i4oztb' --python-tag cp36:
  ERROR: running bdist_wheel
  running build
  running build_py
  package init file 'dlib\__init__.py' not found (or not a regular file)
  running build_ext
  Traceback (most recent call last):
    File "C:\Users\fu\AppData\Local\Temp\pip-install-t50q34ym\dlib\setup.py", line 120, in get_cmake_version
      out = subprocess.check_output(['cmake', '--version'])
    File "f:\python36\lib\subprocess.py", line 356, in check_output
      **kwargs).stdout
    File "f:\python36\lib\subprocess.py", line 423, in run
      with Popen(*popenargs, **kwargs) as process:
    File "f:\python36\lib\subprocess.py", line 729, in __init__
      restore_signals, start_new_session)
    File "f:\python36\lib\subprocess.py", line 1017, in _execute_child
      startupinfo)
  FileNotFoundError: [WinError 2] The system cannot find the specified file.

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "C:\Users\fu\AppData\Local\Temp\pip-install-t50q34ym\dlib\setup.py", line 261, in <module>
      'Topic :: Software Development',
    File "f:\python36\lib\site-packages\setuptools\__init__.py", line 143, in setup
      return distutils.core.setup(**attrs)
    File "f:\python36\lib\distutils\core.py", line 148, in setup
      dist.run_commands()
    File "f:\python36\lib\distutils\dist.py", line 955, in run_commands
      self.run_command(cmd)
    File "f:\python36\lib\distutils\dist.py", line 974, in run_command
      cmd_obj.run()
    File "f:\python36\lib\site-packages\wheel\bdist_wheel.py", line 192, in run
      self.run_command('build')
    File "f:\python36\lib\distutils\cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "f:\python36\lib\distutils\dist.py", line 974, in run_command
      cmd_obj.run()
    File "f:\python36\lib\distutils\command\build.py", line 135, in run
      self.run_command(cmd_name)
    File "f:\python36\lib\distutils\cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "f:\python36\lib\distutils\dist.py", line 974, in run_command
      cmd_obj.run()
    File "C:\Users\fu\AppData\Local\Temp\pip-install-t50q34ym\dlib\setup.py", line 129, in run
      cmake_version = self.get_cmake_version()
    File "C:\Users\fu\AppData\Local\Temp\pip-install-t50q34ym\dlib\setup.py", line 125, in get_cmake_version
      "\n*******************************************************************\n")
  RuntimeError:
  *******************************************************************
   CMake must be installed to build the following extensions: dlib
  *******************************************************************

  ----------------------------------------
  ERROR: Failed building wheel for dlib
  Running setup.py clean for dlib
Failed to build dlib
Installing collected packages: dlib
  Running setup.py install for dlib ... error
    ERROR: Complete output from command 'f:\python36\python.exe' -u -c 'import setuptools, tokenize;__file__='"'"'C:\\Users\\fu\\AppData\\Local\\Temp\\pip-install-t50q34ym\\dlib\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\fu\AppData\Local\Temp\pip-record-4kwg7hfv\install-record.txt' --single-version-externally-managed --compile:
    ERROR: running install
    running build
    running build_py
    package init file 'dlib\__init__.py' not found (or not a regular file)
    running build_ext
    Traceback (most recent call last):
      File "C:\Users\fu\AppData\Local\Temp\pip-install-t50q34ym\dlib\setup.py", line 120, in get_cmake_version
        out = subprocess.check_output(['cmake', '--version'])
      File "f:\python36\lib\subprocess.py", line 356, in check_output
        **kwargs).stdout
      File "f:\python36\lib\subprocess.py", line 423, in run
        with Popen(*popenargs, **kwargs) as process:
      File "f:\python36\lib\subprocess.py", line 729, in __init__
        restore_signals, start_new_session)
      File "f:\python36\lib\subprocess.py", line 1017, in _execute_child
        startupinfo)
    FileNotFoundError: [WinError 2] The system cannot find the specified file.

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\fu\AppData\Local\Temp\pip-install-t50q34ym\dlib\setup.py", line 261, in <module>
        'Topic :: Software Development',
      File "f:\python36\lib\site-packages\setuptools\__init__.py", line 143, in setup
        return distutils.core.setup(**attrs)
      File "f:\python36\lib\distutils\core.py", line 148, in setup
        dist.run_commands()
      File "f:\python36\lib\distutils\dist.py", line 955, in run_commands
        self.run_command(cmd)
      File "f:\python36\lib\distutils\dist.py", line 974, in run_command
        cmd_obj.run()
      File "f:\python36\lib\site-packages\setuptools\command\install.py", line 61, in run
        return orig.install.run(self)
      File "f:\python36\lib\distutils\command\install.py", line 545, in run
        self.run_command('build')
      File "f:\python36\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "f:\python36\lib\distutils\dist.py", line 974, in run_command
        cmd_obj.run()
      File "f:\python36\lib\distutils\command\build.py", line 135, in run
        self.run_command(cmd_name)
      File "f:\python36\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "f:\python36\lib\distutils\dist.py", line 974, in run_command
        cmd_obj.run()
      File "C:\Users\fu\AppData\Local\Temp\pip-install-t50q34ym\dlib\setup.py", line 129, in run
        cmake_version = self.get_cmake_version()
      File "C:\Users\fu\AppData\Local\Temp\pip-install-t50q34ym\dlib\setup.py", line 125, in get_cmake_version
        "\n*******************************************************************\n")
    RuntimeError:
    *******************************************************************
     CMake must be installed to build the following extensions: dlib
    *******************************************************************

    ----------------------------------------
ERROR: Command "'f:\python36\python.exe' -u -c 'import setuptools, tokenize;__file__='"'"'C:\\Users\\fu\\AppData\\Local\\Temp\\pip-install-t50q34ym\\dlib\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\fu\AppData\Local\Temp\pip-record-4kwg7hfv\install-record.txt' --single-version-externally-managed --compile" failed with error code 1 in C:\Users\fu\AppData\Local\Temp\pip-install-t50q34ym\dlib\
WARNING: You are using pip version 19.1, however version 19.1.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

Cmake and boost need to be installed before Dlib is installed. Then Dlib can be installed correctly

pip install boost
pip install cmake
pip install dib

Test installation results:

C:\Users\fu>python
Python 3.6.8 (tags/v3.6.8:3c6b436a57, Dec 24 2018, 00:16:47) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import dlib
>>>

Python ValueError: only 2 non-keyword arguments accepted

Tiger input the following code on the problem, because there is no clear matrix format. Just add a box outside the matrix group. See the following for details.

source code

import time
import numpy as np

A = np.array([56.0, 0.0, 4.4, 68.0],
             [1.2, 104.0, 52.0, 8.0],
             [1.8, 135.0, 99.0, 0.9])

cal=A.sum(axis=0)
print(cal)

After modification

import time
import numpy as np

A = np.array([[56.0, 0.0, 4.4, 68.0],
             [1.2, 104.0, 52.0, 8.0],
             [1.8, 135.0, 99.0, 0.9]])

cal=A.sum(axis=0)
print(cal)

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

Android “handler” is abstract; can’t be identified solution

Today, when I use Android’s own refresh control, I need a handler for instance calls, but I report an error in my own instance calls
“handler” is abstract; can’t be identified
because there is an error in my import library. I use Android’s handler library instead of Java’s handle library
the solution is as follows
use “import” to import android.os.Handler ; ”Replace “import” java.util.logging .Handler;”

This can be solved, in addition to the reference to this blog

Cannot read property ‘this compilation’ of undefined appears in copy webpack plugin

Today, I want to copy the pictures of the company’s projects to build / images,

Direct installation

 npm install copy-webpack-plugin --save-dev

, using the latest official documentation

 new CopyPlugin({
      patterns: [
        { from: 'source', to: 'dest' },
        { from: 'other', to: 'public' },
      ],
    }),

However, it is always reported that cannot read property ‘this compilation’ of undefined

The results show that the webpack is “^ 1.13.2” because the company’s projects are older,

So you can reduce the copy webpack plugin version to below 5.0.0, and then use the old writing method

For example, “copy webpack plugin”: “^ 4.6.0”,

Deep learning: derivation of sigmoid function and loss function

1sigmoid function

1. Derivation from exponential function to sigmoid 2. Logarithm function and sigmoid 2. Sigmoid function 3. Neural network loss function derivation

1. Sigmoid function

Sigmoid function, i.e. S-shaped curve function, is as follows:
0

Function: F (z) = 11 + e − Z

Derivative: F ‘(z) = f (z) (1 − f (z))

The above is our common form. Although we know this form, we also know the calculation process. It’s not intuitive enough. Let’s analyze it.

1.1 from exponential function to sigmoid

First, let’s draw the basic graph of exponential function

From the figure above, we get the following information: the exponential function passes (0,1) point, monotonically increasing / decreasing, and the definition field is

(−∞,+∞)

, the range is

(0,+∞)

Let’s take a look at the image of the sigmoid function

If you just

e−x

If you put it on the denominator, it’s the same as

ex

The image is the same, so add 1 to the denominator to get the image above. The domain of definition is

(−∞,+∞)

, the range is

(0,1)

Then there is a good feature, that is, no matter what

x

We can get the value between (0,1) for whatever it is;

1.2 logarithmic function and sigmoid

First, let’s look at the image of the logarithmic function

Logarithmic function of the image above, monotone decreasing, there is a better feature is in the

(0,1)

If we put the sigmoid function in front of us in the position of the independent variable, we will get the result

(0,1)

The image of the image;

How can we measure the difference between a result and the actual calculation? One idea is that if the result is closer, the difference will be smaller, otherwise, it will be larger. This function provides such an idea. If the calculated value is closer to 1, then it means that it is closer to the world result, otherwise, it is farther away. Therefore, this function can be used as the loss function of logistic regression classifier. If all the results are close to the result value, then The closer it is to 0. If the result is close to 0 after all the samples are calculated, it means that the calculated result is very close to the actual result.

2. Derivation of sigmoid function

The derivation process of sigmoid derivative is as follows:
0

f′(z)=(11+e−z)′=e−z(1+e−z)2=1+e−z−1(1+e−z)2=1(1+e−z)(1−1(1+e−z))=f(z)(1−f(z))

3. Derivation of neural network loss function

The loss function of neural network can be understood as a multi-level composite function, and the chain rule is used for derivation.

J(Θ)=−1m∑i=1m∑k=1K[y(i)klog((hΘ(x(i)))k)+(1−y(i)k)log(1−(hΘ(x(i)))k)]+λ2m∑l=1L−1∑i=1sl∑j=1sl+1(Θ(l)j,i)2

Let’s talk about the process of conventional derivation

e=(a+b)(b+1)

​ This is a simple composite function, as shown in the figure above. C is a function of a and E is a function of C. if we use the chain derivation rule to derive a and B respectively, then we will find out the derivative of e to C and C to a, multiply it, find out the derivative of e to C and D respectively, find out the derivative of C and D to B respectively, and then add it up, One of the problems is that in the process of solving, e calculates the derivative of C twice. If the equation is particularly complex, then the amount of calculation becomes very large. How can we only calculate the derivative once?

As shown in the figure above, we start from top to bottom, calculate the value of each cell, then calculate the partial derivative of each cell, and save it;

​ Next, continue to calculate the value of the sub unit, and save the partial derivatives of the sub unit; multiply all the partial derivatives of the path from the last sub unit to the root node, that is, the partial derivatives of the function to this variable. The essence of calculation is from top to bottom. When calculating, save the value and multiply it to the following unit, so that the partial derivatives of each path only need to be calculated once, from top to bottom All the partial derivatives are obtained by calculating them from top to bottom.

​ In fact, BP (back propagation algorithm) is calculated in this way. If there is a three-layer neural network with input layer, hidden layer and output layer, we can calculate the partial derivative of the weight of the loss function. It is a complex composite function. If we first calculate the partial derivative of the weight of the first layer, and then calculate the partial derivative of the weight of the second layer, we will find that there are some problems A lot of repeated calculation steps, like the example of simple function above, so, in order to avoid this kind of consumption, we use to find the partial derivative from the back to the front, find out the function value of each unit, find out the partial derivative of the corresponding unit, save it, multiply it all the time, and input the layer.

The following is a simple example to demonstrate the process of calculating partial derivative by back propagation

Then we will have two initial weight matrices:

θ1=[θ110θ120θ111θ121θ112θ122]θ2=[θ210θ211θ212]

We got the matrix above, and now we’re using

sigmoid

Function as the activation function to calculate the excitation of each layer of the network (assuming that we have only one sample, the input is

x1,x2,

The output is

y

);

The first level is input, and the incentive is the eigenvalue of the sample

a1=⎡⎣⎢⎢x0x1x2⎤⎦⎥⎥

x0

Is the bias term, which is 1

The second layer is the hidden layer. The excitation is obtained by multiplying the eigenvalue with the region, and then the sigmoid function is used to transform the region

a2

Before transformation

z2

z21z22z2a2a2=θ110∗x0+θ111∗x1+θ112∗x2=θ120∗x0+θ121∗x1+θ122∗x2=[z21z22]=sigmoid(z2)=⎡⎣⎢⎢⎢1a21a22⎤⎦⎥⎥⎥

In the above, we add a bias term at the end;

Next, the third layer is the output layer

z31z3a3a3=θ210∗a20+θ211∗a21+θ212∗a22=[z31]=sigmoid(z3)=[a31]

Because it is the output layer, there is no need to calculate further, so the bias term is not added;

The above calculation process, from input to output, is also called forward propagation.

Then, we write the formula of the loss function according to the loss function. Here, there is only one input and one output, so the loss function is relatively simple

Here, M = 1;
1

J(Θ)=−1m[y(i)klog((hΘ(x(i)))k)+(1−y(i)k)log(1−(hΘ(x(i)))k)]+λ2m∑l=1L−1∑i=1sl∑j=1sl+1(Θ(l)j,i)2=−1m[y∗log(a3)+(1−y)∗log(1−a3)]+λ2m∑l=1L−1∑i=1sl∑j=1sl+1(Θ(l)j,i)2

Note:

λ2m∑L−1l=1∑sli=1∑sl+1j=1(Θ(l)j,i)2

In fact, it is the sum of squares of all the weights. Generally, the one multiplied by the offset term will not be put in. This term is very simple. Ignore it for the time being, and do not write this term for the time being (this is regularization).

J(Θ)=−1m[y∗log(a3)+(1−y)∗log(1−a3)]

Then we get the above formula, and here we know if we want to ask for it

θ212

If we use the partial derivative of, we will find that this formula is actually a composite function,

y

It’s a constant. A3 is a constant

z3

Of

sigmoid

Function transformation, and

z3

then is

a2

Now that we have found where the weight is, we can start to find the partial derivative,

a3

finish writing sth.

s(z3)

Then, we get the following derivation:

∂J(Θ)∂θ212=−1m[y∗1s(z3)−(1−y)∗11−s(z3)]∗s(z3)∗(1−s(z3))∗a212=−1m[y∗(1−s(z3)−(1−y)∗s(z3)]∗a212=−1m[y−s(z3)]∗a212=1m[s(z3)−y]∗a212=1m[a3−y]∗a212

According to the above derivation, we can get the following formula:
1

∂J(Θ)∂θ210∂J(Θ)∂θ211=1m[a3−y]∗a210=1m[a3−y]∗a211

So, remember what I said earlier, we will seek the derivative from top to bottom and save the partial derivative of the current multiple subunits. According to the above formula, we know that the partial derivative of the second weight matrix can be obtained by

[a3−y]

It is obtained by multiplying the excitation of the previous layer of network and dividing it by the number of samples, so sometimes we call the difference as

δ3

Then, the partial derivatives of the second weight matrix are obtained by multiplying them in the form of matrix;

Now that we have obtained the partial derivatives of the second weight matrix, how can we find the partial derivatives of the first weight matrix?

For example, we’re going to

θ112

Partial derivation:
0

∂J(Θ)∂θ112=−1m[y∗1s(z3)−(1−y)∗11−s(z3)]∗s(z3)∗(1−s(z3))∗θ211∗s(z2)∗(1−s(z2))∗x2=−1m∗[a3−y]∗θ211∗s(z2)∗(1−s(z2))∗x2=−1m∗δ3∗θ211∗s(z2)∗(1−s(z2))∗x2

From the formula on the line, we can see that the derivative we saved can be directly multiplied. If there is a multi-layer network, in fact, the following process is the same as this one, so we get the formula:
if there is a multi-layer network, the following process is the same as this one

δ3δ2=a3−y=δ3∗(θ2)T∗s(z2)′

Because this network is three layers, so we can get all the partial derivatives. If it is multi-layer, the principle is the same. Multiply it continuously. Starting from the second formula, the following forms are the same.

Array initializer is not allowed here

Array initializer is not allowed here

The use of array is divided into declaration and initialization, which can be carried out simultaneously or separately

Int [] array; declaration

Array = New Int {element1, Element2, element3..}; initialization mode 1

Array = New Int [length]; initialization mode 2

There are two initialization methods for arrays

1、 Static initialization: the initial value of each array element is explicitly specified by the programmer during initialization;

    arrayName = new type[]{element1,element2,element3…}

2、 Dynamic initialization: when initializing, the programmer specifies the length of the array, and the system initializes the default value of each array element.

    arrayName = new type[length];

Note: do not use static initialization and dynamic initialization at the same time. In other words, do not specify the length of the array and divide each element of the array

The initial value is set.
 

Looking at the code today, we can see a simplified array initialization method, which belongs to the simplified version of static initialization, but there is something wrong with it

Int [] array = {1,2,3}; object [] obj = {}; this is OK

So I tried to write like this

Class member variables declare an array int [] elementdata, but it is not initialized;

Initialize it in the constructor, trying to write like this

Elementdata = {1,3,5}, so the above compilation error prompt appears

It seems that this simplified way of writing is not applicable here,

The use of arrays must be initialized

Suppose that elementdata = {1,3,5} does not generate new objects through new. Maybe the compiler thinks that it has been declared but not initialized

Therefore, it is recommended that the initialization is completed when the array is declared

Int [] elementdata = {1,3,5}; this is OK, declaration and assignment are done at the same time

Latex bold, italics

Latex bold, italics

Show upright text: textup {text}
Italians: textit {text}
slated: Italians: textsl {text}
show small upper case text: textsc {text}
medium weight: textmd {text}
bold command: textbf {text}
default: textnormal {text}

xcode will continue when iPhone is finished iPhone is busy:Processing symbol files

Xcode will continue when iPhone is finished.

There are three reasons for the pop-up interface as shown in the figure below:

first

First mobile connection to Xcode

second

After updating the mobile phone system, connect to Xcode for the first time

third

After updating Xcode, connect your phone for the first time

Snip20170606_ 2.png

Solution:
can only wait.
Connect your cell phone and wait. It will be OK in a moment.

Author: dull and shy

Link: https://www.jianshu.com/p/0e21b4cf7897

Source: Jianshu

The copyright belongs to the author. For commercial reprint, please contact the author for authorization. For non-commercial reprint, please indicate the source.

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)