Tag Archives: python

How to Solve M1 chip import numpy Error

Error report of M1 chip import numpy

Environmental installation method:

miniforge – python3. 9 numpy 1.21.1

Operation error:

## terminal/pycharm error
import numpy
import pandas 

Error Messages:
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:

https://numpy.org/devdocs/user/troubleshooting-importerror.html

At the same time, the python version and numpy version are given, and many files in the miniforge folder no such file are mentioned repeatedly

Solution:

conda install openblas

Import again works normally

How to Solve Python picamera and raspistill error

1. Turn on raspberry pie settings

sudo raspi-config

2. Select the third interface options

3. Turn all options on, and then restart raspberry pie

4.vcgencmd get_camera

The values change to 1, which can not only detect the input, but also identify the device

5. You can execute raspistill and run the python picamera program

For example: raspistill -o /home/pi/Desktop/first.jpg

[Solved] No module named ‘pywt‘ or ModuleNotFoundError: No module named ‘skimage.metrics‘

Solution:

pip install pywavelets
or
pip install scikit-image
The relevant dependencies pywavelets will be installed automatically

If an error is reported later:
modulenotfounderror: no module named ‘skimage metrics‘

If the skimage version is too low, update to the latest version (or 0.18+):

pip install scikit-image --upgrade

[Solved] yolo Error: IndexError: invalid index to scalar variable.

code:

yolo_layers = [layers[i[0] - 1] for i in network.getUnconnectedOutLayers()]

report errors:

Traceback (most recent call last):
  File "Run.py", line 201, in <module>
    main()
  File "Run.py", line 137, in main
    detections = yolo.detect(yolo_img)
  File "code/3D-BoundingBox-master/yolo/yolo.py", line 34, in detect
    ln = [ln[i[0] - 1] for i in self.net.getUnconnectedOutLayers()]
  File "code/3D-BoundingBox-master/yolo/yolo.py", line 34, in <listcomp>
    ln = [ln[i[0] - 1] for i in self.net.getUnconnectedOutLayers()]
IndexError: invalid index to scalar variable.

Reason:
different opencv versions cause different output formats

Solution:

yolo_layers = [layers[i - 1] for i in network.getUnconnectedOutLayers()]

Reference:
https://stackoverflow.com/questions/69834335/loading-yolo-invalid-index-to-scalar-variable

[Solved] Python Pandas Read Error: OSError: initializing from file failed

Problem Description:

error when loading CSV format data in pandas

B = pd.read_csv("C:/Users/hp/Desktop/Hands-On Data Analysis/Unit 1 Project Collection/train.csv")
B.head(3)

report errors:

OSError: Initializing from file failed

Cause analysis:

When calling the read_csv() method of pandas, the C engine is used as the parser engine by default, and when the file name contains Chinese, using the C engine will be wrong in some cases.


Solution:

Specify the engine as Python when calling the read_csv() method

B = pd.read_csv("C:/Users/hp/Desktop/Hands-On-Data-Analysis/Unit-1-Project-Collection/train.csv",engine='python')
B.head(3)

[Solved] original_keras_version = f.attrs[‘keras_version‘].decode(‘utf8‘)

windows system:
original_keras_version = f.attrs[‘keras_version’].decode(‘utf8’)
1. error:

load_weights_from_hdf5_group
    original_keras_version = f.attrs['keras_version'].decode('utf8')

AttributeError: 'str' object has no attribute 'decode'

2. Cause analysis

When installing tensorflow, the default installed h5py is 3.1.0, and an error is reported because the TF you installed does not support an excessively high version of h5py

3. Solutions

1. Uninstall h5py3 Version 1.0, installing h5py2.0 Version 10.0.2. Restart the compiler

pip install h5py==2.10.0

[nltk_data] Error loading wordnet_ic: HTTP Error 404: Not Found

Error loading XXXX: http Error 404: not found
XXXX can be WordNet or nltk_ Any package in data

Solution:

    1. 1. local download

    Find the package you need → copy the corresponding address → download → unzip to “your nltk_data path \nltk_data\corpora”
    For example: “wordnet_ic” “https://raw.githubusercontent.com/nltk/nltk_data/gh-pages/packages/corpora/ wordnet_ic.zip”

    <package id="wordnet_ic" 
    name="WordNet-InfoContent" 
    version="3.0" 
    webpage="http://wn-similarity.sourceforge.net" 
    unzip="1" 
    unzipped_size="34220359" 
    size="12056682" 
    checksum="25f0185b31693fa11ea898e4feda528c" 
    subdir="corpora" 
    url="https://raw.githubusercontent.com/nltk/nltk_data/gh-pages/packages/corpora/wordnet_ic.zip" />
    

    2. Unzip directly
    when we install nltk, XXX.Zip will be included in “your nltk_data path\nltk_data\corpora”. We can first search to see if the package you need exists in the corpora directory. If so, just unzip it directly. Easy.

[Solved] sys.stderr.write(f“ERROR: {exc}“) SyntaxError: invalid syntax

There was an error querying the version of Ubuntu after installing PIP3

Traceback (most recent call last):
  File "/usr/local/bin/pip3", line 7, in <module>
    from pip._internal.cli.main import main
  File "/usr/local/lib/python3.5/dist-packages/pip/_internal/cli/main.py", line 57
    sys.stderr.write(f"ERROR: {exc}")
                                   ^
SyntaxError: invalid syntax

Solution:

wget https://bootstrap.pypa.io/pip/3.5/get-pip.py

After downloading, execute the following command

python3 get-pip.py