Category Archives: Python

Zsh: command not found: pip3 & pip [How to Solve]

Error reporting:

zsh: command not found: pip3

zsh: command not found: pip

Reason: it seems that this problem occurred after my PIP update failed

Solution:

Official website solution

Execute at the terminal first:

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

Get the get pip. Py file in the current directory

Then execute in the current directory:

sudo python3 get-pip.py

Then pip is installed successfully

Django: How to Solve Using Pymysql Error

Environment:
Ubuntu18.04
mysql:8.0
python: 3.6.8
django: 2.2.6
pymysql: 0.9.3

Install pymysql

pip install pymysql

introduce pymysql into Django

under the package with the same name as the project directory__init__. Write the following code to the PY file:

import pymysql

pymysql.install_as_MySQLdb()

configure MySQL in Django, and then start Django service. The errors are as follows:

File "/home/www/.local/share/virtualenvs/EduScore-UXZMOCwv/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 36, in <module>
    raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.__version__)
django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3.

Solution:
Use vim to open /home/www/.local/share/virtualenvs/EduScore-UXZMOCwv/lib/python3.6/site-packages/django/db/backends/mysql/base.py file, and Comment out the following code

#if version < (1, 3, 13):
#    raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.__version__)

start Django server and find or report an error. The error information is:

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

Solution:

find the corresponding file and change the decode of the error line to encode

 

[Solved] OMV 4.x apt install Error: TypeError: ‘NoneType’ object is not callable

problem

After installing OMV (ver. 4.1.22), I intend to install some software with apt , and then I encounter the following error:

Exception ignored in: <function WeakValueDictionary.__init__.<locals>.remove at 0x7f81db3bc730>
Traceback (most recent call last):
  File "/usr/lib/python3.5/weakref.py", line 117, in remove
TypeError: 'NoneType' object is not callable
Exception ignored in: <function WeakValueDictionary.__init__.<locals>.remove at 0x7f81db3bc730>
Traceback (most recent call last):
  File "/usr/lib/python3.5/weakref.py", line 117, in remove
TypeError: 'NoneType' object is not callable

solution

After a search, Google found a solution on GitHub:

First open the /usr/lib/python3.5/weakref.py file:

vim /usr/lib/python3.5/weakref.py

Then change line 109 to

def remove(wr, selfref=ref(self), _atomic_removal=_remove_dead_weakref):

Line 117 should read

_atomic_removal(d, wr.key)

 

WQ save it, and then try apt , and the problem is solved

The Oracle File Attribute change causes the instance to fail to mount the Disk [How to Fix]

surroundings:

DB: 18.3.0.0

OS: Hundreds 7

 

When doing 2-node rac-rac, one node of the standby database cannot be started, and the error message is as follows:
1. Error message
2021-07-19T04:20:26.842539-04:00
ALTER SYSTEM SET remote_listener=’ rac-scan:1521′ SCOPE=MEMORY SID=’oradg2′;
2021-07-19T04:20:26.847739-04:00
ALTER SYSTEM SET listener_networks=” SCOPE=MEMORY SID=’oradg2′;
NOTE: ASM background process initiating disk discovery for grp 2 ( reqid:0)
2021-07-19T04:20:27.703220-04:00
ORA-00210: cannot open the specified control file
ORA-00202: control file:’+DATA/ORADG/CONTROLFILE/current.260.1078285093′
ORA-17503: ksfdopn:2 Failed to open file +DATA/ORADG/CONTROLFILE/current.260.1078285093
ORA-15001: diskgroup “DATA” does not exist or is not mounted
ORA-15040: diskgroup is incomplete
2021-07-19T04:20:27.727000-04:00
ORA-205 signalled during: ALTER DATABASE MOUNT…
2021-07-19T04:20:28.396066-04:00
WARNING: group 2 (DATA) has missing disks
ORA-15040: diskgroup is incomplete
WARNING: group 2 is being dismounted.
WARNING: ASMB force dismounting group 2 (DATA) due to missing disks
SUCCESS: diskgroup DATA was dismounted
2021-07-19T04:21:22.830412-04:00
Decreasing number of high priority LMS from 1 to 0

2. Check the asm disk group
and execute
su-grid
SQL> connect / as sysasm
Connected.
SQL> set linesize 1000;
SQL> select GROUP_NUMBER,NAME,STATE,OFFLINE_DISKS from v$asm_diskgroup;

GROUP_NUMBER NAME STATE OFFLINE_DISKS
———— ———————————————————— ———————- ————-
1 OCR MOUNTED 0
2 DATA MOUNTED 0

SQL> select GROUP_NUMBER,STATE,path,MOUNT_STATUS,state from v$asm_disk;

GROUP_NUMBER STATE PATH MOUNT_STATUS STATE
———— —————- ——————————————————-
1 NORMAL /dev/mapper/ocrdisk02 CACHED NORMAL
2 NORMAL /dev/mapper/datadisk01 CACHED NORMAL
1 NORMAL /dev/mapper/ocrdisk03 CACHED NORMAL
1 NORMAL /dev/mapper/ocrdisk01 CACHED NORMAL

3. Check the attribute
node 2 of the oracle file, the node that reported the error
[root@rac02 ~]# su-oracle
[oracle@rac02 ~]$ ls -al /u01/oracle/app/product/18.0.0/db_1/bin/ oracle
-rwsr-s–x 1 oracle oinstall 436992448 Jul 16 04:49 /u01/oracle/app/product/18.0.0/db_1/bin/oracle

Normal node
[root@rac01 ~]# su-oracle
[oracle@rac01 bin]$ ls -al /u01/oracle/app/product/18.0.0/db_1/bin/oracle
-rwsr-s–x 1 oracle asmadmin 436992448 Jul 16 04:45 /u01/oracle/app/product/18.0.0/db_1/bin/oracle

Found that the attributes of the file have changed

Solution:
[root@rac02 ~]#chmod u+s /u01/oracle/app/product/18.0.0/db_1/bin/oracle
[root@rac02 ~]#chmod g+s /u01/oracle/app/ product/18.0.0/db_1/bin/oracle
[root@rac02 ~]#chown oracle:asmadmin /u01/oracle/app/product/18.0.0/db_1/bin/oracle

[Solved] RuntimeError: Input type (torch.cuda.FloatTensor) and weight type (torch.FloatTensor) should be the same

The error content is: the input is cuda type data, but the weight type used is not, and their types should be the same.

Solution :

Just change your network model to the cuda type (before using the model).

Such as model_class = yourModelName()

old version:   model_class(x)

new version: model_class.cuda()

model_class(x)

[Solved] Python TensorFlow Error: ‘tensorflow.compat.v2.__internal__’ has no attribute ‘tf2’

This article mainly introduces Python, when using TensorFlow, execute import Keras error: AttributeError: module’tensorflow.compat.v2.__internal__’ has no attribute’tf2′ solution.

Sample code:

# Install required libs  
# NOTE: Run this one code, then restart this runtime and run again for next all... (PENTING!!!) 
### please update Albumentations to version>=0.3.0 for `Lambda` transform support
!pip install -U segmentation-models
!pip install q tensorflow==2.1
!pip install q keras==2.3.1
!pip install tensorflow-estimator==2.1.
## Imports libs
import os
os.environ [ 'CUDA_VISIBLE_DEVICES' ] = '0'

import cv2
import Keras
import NumPy as np
import matplotlib.pyplot as plt

Error message:

AttributeError                            Traceback (most recent call last)
<ipython-input-3-9c78a7be919d> in <module>()
      5 
      6 import cv2
----> 7 import keras
      8 import numpy as np
      9 import matplotlib.pyplot as plt
8 frames
/usr/local/lib/python3.7/dist-packages/keras/initializers/__init__.py in populate_deserializable_objects()
     47 
     48   LOCAL.ALL_OBJECTS = {}
---> 49   LOCAL.GENERATED_WITH_V2 = tf.__internal__.tf2.enabled()
     50 
     51   # Compatibility aliases (need to exist in both V1 and V2).
AttributeError: module 'tensorflow.compat.v2.__internal__' has no attribute 'tf2'

Solution:

!pip install -U -q segmentation-models
!pip install -q tensorflow==2.1
!pip install -q keras==2.3.1
!pip install -q tensorflow-estimator==2.1.
## Imports libs
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
os.environ["SM_FRAMEWORK"] = "tf.keras"
from tensorflow import keras
import segmentation_models as sm

[Solved] Error when calling different modules of Python functions: ModuleNotFoundError: No module named’python_base.test1′;’python_base’ is not a package

Function call being given different modules: ModuleNotFoundError: No Module1 the named ‘python_base.test1’; ‘python_base’ IS Not A Package ( ModuleNotFoundError: No module named ‘python_base.test1’ a; ‘python_base’ is not a package )

It is found that there is a py file with the same name under the package package, which causes an error to be reported when the call is made. (It is hereby recorded to prevent such low-level mistakes from being made in the future!)

Two other points to note:

 

[Solved] Python Selenium Chromedriver Error: (Passthrough is not supported, GL is disabled)

This article mainly introduces the solution of using selenium and webdriver_manager to crawl websites in Python, and the error: ERROR:gpu_init.cc(426) Passthrough is not supported, GL is disabled or Passthrough is not supported, GL is swiftshader.

Error message :Passthrough is not supported, GL is swiftshader

Solution:

The error message Passthrough is not supported, GL is swiftshadermay be the error message displayed after Chromedriver version 89.

When using chromedriver, you generally need to specify --headlessand --disable-gpuparameters, and the browser window may not be displayed. If you do not use these two options, no error message will appear.

You can also use the --disable-software-rasterizerparameter to disable it WebGL, and no error message will be displayed in the mode that does not display the window.

Error message :Passthrough is not supported, GL is disabled)

Solution : If the above method cannot -enable-webgl --no-sandbox --disable-dev-shm-usagebe solved , you can also try to solve it with parameters.

[Solved] Pycharm Pytest Error: UnicodeDecodeError: ‘gbk’ codec can’t decode byte 0xaa in position 171: illegal multibyte sequence

UnicodeDecodeError:’gbk’ codec can’t decode byte 0xaa in position 171: illegal multibyte sequence

 

Check if there is a pytest.ini configuration file in the root directory.

Solution:

1. It is necessary to delete all the Chinese comments and also delete

2. In the pytest.ini file, change utf-8 to gbk in the lower right corner