KeyError: “Can’t open attribute (can’t locate attribute: ‘nrx’)”
api(filename,n=8,geometry_only=True)
Where geometry_ Change the only parameter to false
KeyError: “Can’t open attribute (can’t locate attribute: ‘nrx’)”
api(filename,n=8,geometry_only=True)
Where geometry_ Change the only parameter to false
Problem description
Running a python flash project on a new machine causes the following problems:
error: while importing 'run_ app_ dev', an ImportError was raised.
resolvent
It is said on the Internet that it is a circular call problem, but this project can run on my laptop. I doubt whether it is the version of flash, because I directly installed the latest Flash. After uninstalling the latest flash, I installed 1.1.2 flash. This problem is solved
Problem Description:
After installing Anaconda 3, open the Jupiter notebook to create a new one. When you click Python 3, the kernel error is always displayed. It has been tried several times. I believe many people have such a problem. No matter uninstalling and reloading Anaconda or rebuilding an environment, it has not been solved. Until later, it was found that the nuclear was not cleaned up. Here I share a solution to this problem. Successfully solved my problem.
solve:
1. Open the anaconda prompt window and enter Jupiter kernelspec list to see the location of the current kernel. Note that this is the wrong kernel,
2. Copy this address and uninstall the current anaconda
3. Find the address just now and delete the jupyter folder
4. Reinstall Anaconda
It can be solved!!
Learn ROS in linunx system. During the programming process of testing publisher publisher, execute ‘learn’ to be tested_ The following error occurred while publishing. Py ‘file:
resolvent:
In ‘learn_ Add code on the first line of the publish. Py ‘file: #/ Usr/bin/env python, click “save” in the upper right corner after adding.
The operation is as follows:
Solution
add the following code to the PY header of the operation picture:
from PIL import JpegImagePlugin
JpegImagePlugin._getmp = lambda x:None
mime = mimetypes.types_ Map [true] [ext]
keyerror: ‘. MPO’
the above error occurs when using openpyxl to operate the pictures in Excel. Baidu has not. After a visit to Google, it is found that there is an image MIME type of. MPO, and the pictures in my excel are clearly in. PNG format
examples are as follows:
>>> import PIL.Image
>>> img = PIL.Image.open('bob a.jpg')
>>> img.format
'MPO'
>>> PIL.PILLOW_VERSION
'2.7.0'
First of all, you should know that openpyxl uses pilot to identify images. After Google found that this PNG image is recognized as an. MPO file by pilot, Openpyxl does not support
while images in MPO format are very similar to JPEG images
it may be that an additional flag is added when the pilot recognition format is JPEG or PNG and marked as MPO
so we can add the above two lines of code before importing any image and before the pilot recognition image (I don’t know what he means. The jpeimageplugin is used by the pilot to process images. It should not add any suffix to the source image).
Reference link
using openpyxl: keyerror: ‘. MPO’ while saving excel workbook
k
JPEG image being identified as MPO
Open a named PI with absolute path under windows_ The file of digits.txt has an error
Because the resource of the path cannot be found after escape.
To change a \ in the absolute path to\\
This is the path before the error is reported.
The path that runs successfully after modification.
Moreover, it can be found that it is not necessary to replace all \ \, replace the front with \ \, and run without changing the back.
Error:
When specifying the file path with Python, the error ‘syntax error: (Unicode error)’ Unicode escape ‘codec can’t decode bytes in position 2-3: truncated \ uxxxxxxxx escape’ may occur.
The reason for the error is that “\” is used in a string such as a path, which is treated as an escape sequence. In the windows environment, the combination of ‘\’ and characters represents an escape sequence. Python provides escape sequences including \\(backslash) and \n (line spacing).
Generally speaking, the path is as follows:
C:\Users\Desktop\myproject
Solution:
Windows:
Use the escape sequence “\\” representing the backslash (on windows\), as follows:
C:\\Users\\Desktop\\myproject
Unix:
Use “/” to separate directories
C:/Users/Desktop/myproject
Python error resolution: error: spider error processing
Background
Demand: crawl data of a website (including product pictures, book names and prices) using scratch
Question
After the project is created, the spider file is created and the code is written. Error: spider error processing
Solution
Match the attributes defined in the item.py file one by one
insert the picture description here
json.decoder.JSONDecodeError: Expecting value: line 1 column 26 (char 25)
Cause: JSON format conversion error, not standard JSON format
Note:
(1) the parentheses indicate the object. The object must be composed of attributes, which are composed of key value pairs
(2) Use double quotation marks for attribute values in JSON
(3) If the attribute value in JSON is a logical value or null value, it must be lowercase, false, true and null
① true in JSON, true in Python
② false in JSON, false in Python
③ null in JSON and none in Python
(4) Conversion between JSON data type and Dictionary (pre operation pilot library → import JSON):
① convert JSON to dictionary → JSON. Loads()
② convert dictionary to JSON → JSON. Dumps()
~/opencv_contrib/modules/xfeatures2d/src/boostdesc.cpp:673:20: fatal error: boostdesc_bgm.i: No such file or directory
Solution:
Check the /home/pi/Downloads/opencv-3.4.0/build/CMakeDownloadLog.txt log file, search for boostdesc_bgm.i keyword in the log file CMakeDownloadLog.txt, and find that the download of this file has failed.
A total of 11 files were found to be missing as follows:
boostdesc_bgm.i
boostdesc_bgm_bi.i
boostdesc_bgm_hd.i
boostdesc_lbgm.i
boostdesc_binboost_064.i
boostdesc_binboost_128.i
boostdesc_binboost_256.i
vgg_generated_120.i
vgg_generated_64.i
vgg_generated_80.i
vgg_generated_48.i
Download and upzip. put them in the path of /home/pi/Downloads/opencv_contrib3.4.0/modules/xfeatures2d/src/
is OK.
Then re-compile:
make clean
make
>>> import tensorflow as tf
>>> tf.__version__
'2.6.0'
Error code snippet:
model.compile(optimizer=tf.train.AdampOptimizer(0.001),
loss='mse',
metrics=['accuracy'])
Replace with:
from tensorflow.keras.optimizers import Adam
model.compile(optimizer=Adam(learning_rate=0.001), loss='mse', metrics=['accuracy'])
It can also be changed as follows:
model.compile(optimizer='adam',
loss='mse',
metrics=['accuracy'])
Both are operational.
Error in installing backups.lzma for Python on Linux
pip3.9 install backports.lzma
Error Message:
Running setup.py install for backports.lzma … error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3.9 -u -c ‘import io, os, sys, setuptools, tokenize; sys.argv[0] = ‘”’”’/tmp/pip-install-pnrkhuf9/backports-lzma_24feded447a34e5a8b1c53cb80e10341/setup.py’”’”’; file=’”’”’/tmp/pip-install-pnrkhuf9/backports-lzma_24feded447a34e5a8b1c53cb80e10341/setup.py’”’”’;f = getattr(tokenize, ‘”’”‘open’”’”’, open)(file) if os.path.exists(file) else io.StringIO(’”’”‘from setuptools import setup; setup()’”’”’);code = f.read().replace(’”’”’\r\n’”’”’, ‘”’”’\n’”’”’);f.close();exec(compile(code, file, ‘”’”‘exec’”’”’))’ install –record /tmp/pip-record-tcqknwy3/install-record.txt –single-version-externally-managed –compile –install-headers /usr/local/python3.9/include/python3.9/backports.lzma
cwd: /tmp/pip-install-pnrkhuf9/backports-lzma_24feded447a34e5a8b1c53cb80e10341/
Complete output (21 lines):
This is backports.lzma version 0.0.14
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.9
creating build/lib.linux-x86_64-3.9/backports
copying backports/init.py -> build/lib.linux-x86_64-3.9/backports
creating build/lib.linux-x86_64-3.9/backports/lzma
copying backports/lzma/init.py -> build/lib.linux-x86_64-3.9/backports/lzma
running build_ext
building ‘backports.lzma._lzma’ extension
creating build/temp.linux-x86_64-3.9
creating build/temp.linux-x86_64-3.9/backports
creating build/temp.linux-x86_64-3.9/backports/lzma
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/local/python3.9/include -I/root/include -I/opt/local/include -I/usr/local/include -I/usr/local/python3.9/include/python3.9 -c backports/lzma/_lzmamodule.c -o build/temp.linux-x86_64-3.9/backports/lzma/_lzmamodule.o
backports/lzma/_lzmamodule.c:115:10: fatal error: lzma.h: No such file or directory
#include <lzma.h>
^~~~~~~~
compilation terminated.
error: command ‘/usr/bin/gcc’ failed with exit code 1
—————————————-
ERROR: Command errored out with exit status 1: /usr/bin/python3.9 -u -c ‘import io, os, sys, setuptools, tokenize; sys.argv[0] = ‘”’”’/tmp/pip-install-pnrkhuf9/backports-lzma_24feded447a34e5a8b1c53cb80e10341/setup.py’”’”’; file=’”’”’/tmp/pip-install-pnrkhuf9/backports-lzma_24feded447a34e5a8b1c53cb80e10341/setup.py’”’”’;f = getattr(tokenize, ‘”’”‘open’”’”’, open)(file) if os.path.exists(file) else io.StringIO(’”’”‘from setuptools import setup; setup()’”’”’);code = f.read().replace(’”’”’\r\n’”’”’, ‘”’”’\n’”’”’);f.close();exec(compile(code, file, ‘”’”‘exec’”’”’))’ install –record /tmp/pip-record-tcqknwy3/install-record.txt –single-version-externally-managed –compile –install-headers /usr/local/python3.9/include/python3.9/backports.lzma Check the logs for full command output.
Solution:
apt install -y liblzma-dev #ubuntu
yum install -y xz-devel #centos
At this point, there is no problem when executing pip3.9 install backups.lzma