Tag Archives: python

[Solved] SyntaxError: (unicode error) ‘unicodeescape‘ codec can‘t decode bytes in position 10-11: malformed

#Read a *.txt file using the read_table() function in the Pandas library
data = pd.read_table(r'D:\New\test.txt',delimiter=',',encoding = 'UTF-8')
print(data)

Title defect Solution: add “R” before the path to solve it.

python D:\New\MyTest.py
        name  date   id
0   jianghu  20210201  00001
1  jianghu1  20210202  00002
2  jianghu2  20210203  00003

 

MAC install lightgbm and xgboost Error [How to Solve]

MAC system + anaconda3 + Python 3 eight point eight

The two integrated learning algorithm packages lightgbm and xgboost were successfully installed
, but errors were always reported during import

---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
<ipython-input-5-b18b3f8a6dc8> in <module>
----> 1 import lightgbm

dlopen(/Users/kumahiroshi/opt/anaconda3/lib/python3.8/site-packages/lightgbm/lib_lightgbm.so, 6): Library not loaded: /usr/local/opt/libomp/lib/libomp.dylib
  Referenced from: /Users/kumahiroshi/opt/anaconda3/lib/python3.8/site-packages/lightgbm/lib_lightgbm.so
  Reason: image not found

Always report: oserror reason: image not found

After consulting the data, it is found that you only need to re import this line of code after running on the terminal: brew install libomp


brew install libomp

Done!
Need to install: Homebrew,
Install commands:ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

[Solved] RuntimeError An attempt has been made to start a new process

1、 Exception 1: runtimeerror: an attempt has been made to start a new process

Reason: multiple processes need to run in the main function

Solution 1:

Add the main function and call it in main.

if __name__ == '__main__':
	main()

Solution 2:

num_workers changed to 0, single process loading

Ers changed to 0, single process loading

[Solved] ERROR: Cannot uninstall ‘PyYAML‘. It is a distutils installed project and thus we cannot accurately

ERROR: Cannot uninstall ‘PyYAML’. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
Problem Description.
When installing transformers, an error is reported: “ERROR: Cannot uninstall ‘PyYAML’. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.”

pip install transformers 

Solution:

You only need to modify the original installation command to:

pip install transformers --ignore-installed PyYAML

Just.

Similar problems can be solved in this way.

[Solved] Conda install Error: An HTTP error occurred when trying to retrieve this URL. HTTP errors are often…

1. Problem Description: prepare to execute the following command in Anaconda prompt:

conda install -c stellargraph stellargraph

An HTTP error occurred when trying to retrieve this URL

HTTP errors are often intermittent, and a simple retry will get you on your way.

2. Solution: open “C:\users\your computer name\condarc

Delete all lines in condarc, copy and paste the following code, and then save:

channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
  - defaults
show_channel_urls: true
ssl_verify: true

(anyway, I can finally succeed in this file with the above code. I don’t know if you can do it.

3. Re run

conda install -c stellargraph stellargraph
    1. as long as you don’t report an error (try it several times, it may not work well). Maybe it will take a long time. Please be patient. If you want to improve the speed, you’d better create a new virtual environment and install the software, which will be much faster

Create a new environment ( CONDA env create - n env_name ) and install the software. In this way, the compatibility with the existing software will not be considered. It can also greatly reduce the search space and improve the speed of resolving software dependencies.

[Solved] ERROR: Cannot uninstall ‘wrapt‘. It is a distutils installed project and thus we cannot accurately d

ERROR: Cannot uninstall ‘wrapt’. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
Problem Description.
When installing tensorflow, an error is reported: “ERROR: Cannot uninstall ‘wrapt’. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.”

pip install tensorflow==1.15.0

Solution:

Change the command to:

pip install tensorflow==1.15.0 --ignore-installed wrapt

[Solved] SyntaxError: Generator expression must be parenthesized (widgets.py, line 152)

Run Django with pycharm, python manage Py runserver error

Checked the Internet and said to put widgets Delete the comma in line 152 of Py, which may be a compatibility problem between Python and Django. Try it. You can click the hyperlink above. Pycharm can quickly open the document, and then find the widgets under admin Py file is OK, because the prompt says form Django contrib. Admin import helpers, widgets, and options The PY file is in the admin directory.