fatal error: cublas_v2.h: No such file or directory
Reason for error: nvidia graphics card CUDA is not installed
Check the CUDA version: nvcc -V
Install CUDA:sudo apt install nvidia-cuda-toolkit
Category Archives: Python
[Solved] Django Error: django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.
1. Background
Because you want to change the default database of Django to MySQL, the following error is reported when starting the project
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.
2. Solution
From the above results, it can be seen that the corresponding module cannot be identified, so the corresponding module needs to be modified __ init__.Py file
import pymysql
pymysql.install_as_MySQLdb()
Just start the service again
[Solved] AttributeError: DataFrame object has no attribute’xxx’
Problem Description:
After reading a column of information in the table (full [‘power ‘]. Describe()),
Error ‘dataframe’ object has no attribute ‘power’ occurred
Problem-solving:
Find the table header and find that there is more space in “power” when naming the header. Delete the space
[Solved] AttributeError: module ‘logging‘ has no attribute ‘Handler‘
Traceback (most recent call last):
File "/home/odoo/python-dev/python_interview_exercise/python_libs/0-pandas.py", line 3, in <module>
import numpy
File "/home/odoo/.local/lib/python3.6/site-packages/numpy/__init__.py", line 223, in <module>
from .testing import Tester
File "/home/odoo/.local/lib/python3.6/site-packages/numpy/testing/__init__.py", line 8, in <module>
from unittest import TestCase
File "/usr/lib/python3.6/unittest/__init__.py", line 59, in <module>
from .case import (TestCase, FunctionTestCase, SkipTest, skip, skipIf,
File "/usr/lib/python3.6/unittest/case.py", line 278, in <module>
class _CapturingHandler(logging.Handler):
AttributeError: module 'logging' has no attribute 'Handler'
Solution:
the file name is logging.py and renamed to another name, such as demo_logging.py
[Solved] AttributeError: ‘_IncompatibleKeys’ object has no attribute
The error code is as follows:
# Error code!
model = model.load_state_dict(state_dict_var)
out = model(input)
There are some problems on the Internet because the saved model uses state_ DCIT() to load, or vice versa.
The error here is different from the above because xxx.load_state_Dict() does not require a return value to receive.
Amend to read as follows:
# Correct code!
model.load_state_dict(state_dict_var)
out = model(input)
I hope it will help more people.
[Solved] PyCharm Error: Cannot open Local Terminal Failed to start [powershell.exe] in C:\Users\…….
1. Whether there is a problem with the set path (it is only possible, and sometimes it can be modified without modification)
File– Settings
– Terminal
Modify shell path powershell.exe to
C:\Windows\System32\cmd.exe
.
2. Check the computer environment variables (here is the key point)
This computer – properties – advanced system settings – environment variables – path check environment
C:\Windows\system32
C:\Windows
C:\Windows\System32\Wbem
C:\Windows\System32\WindowsPowerShell\v1.0\
[Solved] gyp verb `which` failed Error: not found: python2
Problems with yarn install
1. No yarn
NPM install – G yarn
2. An error is reported and phthon is not found
yarn install v1.22.17
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynch
ronized lock files. To clear this warning, remove package-lock.json.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning " > [email protected]" has unmet peer dependency "css-loader@*".
warning " > [email protected]" has unmet peer dependency "webpack@^3.0.0 || ^4.1.0 || ^5.0.0-0".
warning " > [email protected]" has unmet peer dependency "webpack@^2.0.0 || ^3.0.0 || ^4.0.0".
warning " > [email protected]" has unmet peer dependency "webpack@^3.0.0 || ^4.0.0".
[4/4] Building fresh packages...
[7/7] ⠈ ant-design-vue
[-/7] ⠁ waiting...
[6/7] ⠁ node-sass
[4/7] ⠁ yorkie
error E:\HuaDi\Projects\mrpc-inline\ant-design-vue-supermap\node_modules\node-sass: Command failed.
Exit code: 1
Command: node scripts/build.js
Arguments:
Directory: E:\HuaDi\Projects\mrpc-inline\ant-design-vue-supermap\node_modules\node-sass
Output:
Building: E:\develop\node.js\node.exe E:\HuaDi\Projects\mrpc-inline\ant-design-vue-supermap\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libs
ass_library=
gyp info it worked if it ends with ok
gyp verb cli [
gyp verb cli 'E:\\develop\\node.js\\node.exe',
gyp verb cli 'E:\\HuaDi\\Projects\\mrpc-inline\\ant-design-vue-supermap\\node_modules\\node-gyp\\bin\\node-gyp.js',
gyp verb cli 'rebuild',
gyp verb cli '--verbose',
gyp verb cli '--libsass_ext=',
gyp verb cli '--libsass_cflags=',
gyp verb cli '--libsass_ldflags=',
gyp verb cli '--libsass_library='
gyp verb cli ]
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
gyp verb `which` failed at getNotFoundError (E:\HuaDi\Projects\mrpc-inline\ant-design-vue-supermap\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (E:\HuaDi\Projects\mrpc-inline\ant-design-vue-supermap\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (E:\HuaDi\Projects\mrpc-inline\ant-design-vue-supermap\node_modules\which\which.js:80:29)
gyp verb `which` failed at E:\HuaDi\Projects\mrpc-inline\ant-design-vue-supermap\node_modules\which\which.js:89:16
gyp verb `which` failed at E:\HuaDi\Projects\mrpc-inline\ant-design-vue-supermap\node_modules\isexe\index.js:42:5
gyp verb `which` failed at E:\HuaDi\Projects\mrpc-inline\ant-design-vue-supermap\node_modules\isexe\windows.js:36:5
gyp verb `which` failed at FSReqCallback.oncomplete (fs.js:175:21)
gyp verb `which` failed python2 Error: not found: python2
gyp verb `which` failed at getNotFoundError (E:\HuaDi\Projects\mrpc-inline\ant-design-vue-supermap\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (E:\HuaDi\Projects\mrpc-inline\ant-design-vue-supermap\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (E:\HuaDi\Projects\mrpc-inline\ant-design-vue-supermap\node_modules\which\which.js:80:29)
gyp verb `which` failed at E:\HuaDi\Projects\mrpc-inline\ant-design-vue-supermap\node_modules\which\which.js:89:16
gyp verb `which` failed at E:\HuaDi\Projects\mrpc-inline\ant-design-vue-supermap\node_modules\isexe\index.js:42:5
gyp verb `which` failed at E:\HuaDi\Projects\mrpc-inline\ant-design-vue-supermap\node_modules\isexe\windows.js:36:5
gyp verb `which` failed at FSReqCallback.oncomplete (fs.js:175:21) {
gyp verb `which` failed code: 'ENOENT'
gyp verb `which` failed }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` failed Error: not found: python
gyp verb `which` failed at getNotFoundError (E:\HuaDi\Projects\mrpc-inline\ant-design-vue-supermap\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (E:\HuaDi\Projects\mrpc-inline\ant-design-vue-supermap\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (E:\HuaDi\Projects\mrpc-inline\ant-design-vue-supermap\node_modules\which\which.js:80:29)
gyp verb `which` failed at E:\HuaDi\Projects\mrpc-inline\ant-design-vue-supermap\node_modules\which\which.js:89:16
gyp verb `which` failed at E:\HuaDi\Projects\mrpc-inline\ant-design-vue-supermap\node_modules\isexe\index.js:42:5
gyp verb `which` failed at E:\HuaDi\Projects\mrpc-inline\ant-design-vue-supermap\node_modules\isexe\windows.js:36:5
gyp verb `which` failed at FSReqCallback.oncomplete (fs.js:175:21)
gyp verb `which` failed python Error: not found: python
gyp verb `which` failed at getNotFoundError (E:\HuaDi\Projects\mrpc-inline\ant-design-vue-supermap\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (E:\HuaDi\Projects\mrpc-inline\ant-design-vue-supermap\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (E:\HuaDi\Projects\mrpc-inline\ant-design-vue-supermap\node_modules\which\which.js:80:29)
gyp verb `which` failed at E:\HuaDi\Projects\mrpc-inline\ant-design-vue-supermap\node_modules\which\which.js:89:16
gyp verb `which` failed at E:\HuaDi\Projects\mrpc-inline\ant-design-vue-supermap\node_modules\isexe\index.js:42:5
gyp verb `which` failed at E:\HuaDi\Projects\mrpc-inline\ant-design-vue-supermap\node_modules\isexe\windows.js:36:5
gyp verb `which` failed at FSReqCallback.oncomplete (fs.js:175:21) {
gyp verb `which` failed code: 'ENOENT'
gyp verb `which` failed }
gyp verb could not find "python". checking python launcher
gyp verb could not find "python". guessing location
gyp verb ensuring that file exists: C:\Python27\python.exe
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack at PythonFinder.failNoPython (E:\HuaDi\Projects\mrpc-inline\ant-design-vue-supermap\node_modules\node-gyp\lib\configure.js:484:19)
gyp ERR! stack at PythonFinder.<anonymous> (E:\HuaDi\Projects\mrpc-inline\ant-design-vue-supermap\node_modules\node-gyp\lib\configure.js:509:16)
gyp ERR! stack at callback (E:\HuaDi\Projects\mrpc-inline\ant-design-vue-supermap\node_modules\graceful-fs\polyfills.js:295:20)
gyp ERR! stack at FSReqCallback.oncomplete (fs.js:175:21)
gyp ERR! System Windows_NT 10.0.19042
gyp ERR! command "E:\\develop\\node.js\\node.exe" "E:\\HuaDi\\Projects\\mrpc-inline\\ant-design-vue-supermap\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cfla
gs=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd E:\HuaDi\Projects\mrpc-inline\ant-design-vue-supermap\node_modules\node-sass
gyp ERR! node -v v14.1.0
Solution:
1. Install low version node.js
2.npm install -g node-gyp
3.yarn install
VScode import numpy Error: DLL load failed [How to Solve]
vscode & Anaconda import numpy failed: DLL load failed
Phenomenon:
in Anaconda prompt, import numpy is normal
in vscode, import numpy reports an error: DLL load failed
Error reason:
shell opening failed, resulting in CONDA activate failure. There is no environment, and naturally there is no numpy
Solution:
open the vscodesettings.json file
(type) CTRL + SHIFT + P
(search for:) open settings
(click:) Preferences: Open Settings (JSON)
Add in settings.json:
"terminal.integrated.profiles.windows":{
"PowerShell": {
"source": "PowerShell",
"icon": "terminal-powershell"
},
"Command Prompt": {
"path": [
"${env:windir}\\Sysnative\\cmd.exe",
"${env:windir}\\System32\\cmd.exe"
],
"args": [],
"icon": "terminal-cmd"
},
"Git Bash": {
"source": "Git Bash"
}
},
"terminal.integrated.defaultProfile.windows":"Command Prompt"
In addition, I also refer to another blog. You need to configure the environment variable
and put the following contents into this computer -> Attribute -> Advanced system settings -> Environment variable -> Path path:
D:\anaconda
D:\anaconda\Scripts
D:\anaconda\Library\bin
D:\anaconda\Library\user\bin
D:\anaconda\Library\mingw-w64\bin
[Solved] Failed to obtain/convert traceback after Python Tkinter packages exe
Exe in Python Tkinter packaging causes failed to obtain/convert traceback!
Problem description
python 3.9
windows 10
Packaged and executed commands
pyinstaller -D -w -i xx.ico main.py
After using pyinstaller to package exe, click the EXE file and an error occurs
failed to obtain/convert traceback
the details are shown in the figure:
Cause of problem
After troubleshooting, it is found that there is no problem with the packaged commands. The problem is that the database does not import data during initialization. The data is null. Just fill in the corresponding database values
summary: the problem is that the code does not handle exceptions properly.
solve the problem
- handle the corresponding code exceptions (including those where exceptions may occur) and populate the database
[Solved] pycuda._driver.LogicError: cuFuncSetBlockShape failed: invalid resource handle
Invalid resource handle error in pycuda code
When running CUDA code, the following error occurs:
File "/mnt/lustre/demo/extract_disp_newtopo/face_registration-master/code/poisson.py", line 147, in blend_gs_cuda
block = (1024, 1, 1))
File "/mnt/lustre/miniconda3/envs/pycuda/lib/python3.6/site-packages/pycuda/driver.py", line 436, in function_call
func._set_block_shape(*block)
pycuda._driver.LogicError: cuFuncSetBlockShape failed: invalid resource handle
Solution:
find the CUDA function part with the problem:
mod = SourceModule("""
#include <stdint.h>
__global__ void construct_b(
const uint8_t* src, const int16_t* u, const int16_t* v,
float* b,
int pix_num, int size
)
You can add any sentence in the following code before the function declaration
src = torch.cuda.ByteTensor(8)# Fill in the numbers at will, and the matrix is also fine, but the data type should be consistent with the data type in C++
b = torch.cuda.FloatTensor(9)
The complete code is as follows:
src = torch.cuda.ByteTensor(8)
mod = SourceModule("""
#include <stdint.h>
__global__ void construct_b(
const uint8_t* src, const int16_t* u, const int16_t* v,
float* b,
int pix_num, int size
)
The specific reason is unknown because it occurs occasionally.
[Solved] TensorFlow Error: GetNext() failed because the iterator has not been initialized
Error Messages:
FailedPreconditionError (see above for traceback): GetNext() failed because the iterator has not been initialized. Ensure that you have run the initializer operation for this iterator before getting the next element. [[Node: IteratorGetNext = IteratorGetNextoutput_shapes=[, ], output_types=[DT_UINT8, DT_UINT8], _device=”/job:localhost/replica:0/task:0/device:CPU:0″]]
Solution:
Iterator is not initialized
Add before the error code: sess.run(iterator.initializer)
error: (-5:Bad argument) in function ‘seamlessClone‘ and error: (-215:Assertion failed) 0 <= roi.x && 0 [How to Solve]
Error code in this document
# Pay attention to modify the path!
import cv2
import numpy as np
# Read images : src image will be cloned into dst
obj= cv2.imread("src.jpg")
im = cv2.imread("dst.jpg")
# Create an all white mask
mask = 255 * np.ones(obj.shape, im.dtype)
# The location of the center of the src in the dst
width, height, channels = im.shape
center = (height/2, width/2)
# Seamlessly clone src into dst and put the results in output
normal_clone = cv2.seamlessClone(obj, im, mask, center, cv2.NORMAL_CLONE)
mixed_clone = cv2.seamlessClone(obj, im, mask, center, cv2.MIXED_CLONE)
# Write results
cv2.imwrite("normal.jpg", normal_clone)
cv2.imwrite("mixed.jpg", mixed_clone)
The picture is as follows among dst.jpg:
The picture (src.jpg) is as follows
Error message:
cv2.error: OpenCV(4.5.3) :-1: error: (-5:Bad argument) in function 'seamlessClone'
The screenshot is as follows:
Analysis reason:
The reason for finding the error is that the coordinates of the two input into the CV2. Rectangle () function cannot be the type of floating point number, but must be converted to an integer. Therefore, int () is used to force type conversion. After that, the code successfully has this bug and becomes another bug.
Solution:
Add int() Strong return of floating point numbers Int type
The modified code is as follows
# Pay attention to modify the path!
import cv2
import numpy as np
# Read images : src image will be cloned into dst
obj= cv2.imread("src.jpg")
im = cv2.imread("dst.jpg")
# Create an all white mask
mask = 255 * np.ones(obj.shape, im.dtype)
# The location of the center of the src in the dst
width, height, channels = im.shape
center = (int(height/2), int(width/2))
# Seamlessly clone src into dst and put the results in output
normal_clone = cv2.seamlessClone(obj, im, mask, center, cv2.NORMAL_CLONE)
mixed_clone = cv2.seamlessClone(obj, im, mask, center, cv2.MIXED_CLONE)
# Write results
cv2.imwrite("normal.jpg", normal_clone)
cv2.imwrite("mixed.jpg", mixed_clone)
Then run
Found another more exotic bug
cv2.error: OpenCV(4.5.3) C:\Users\runneradmin\AppData\Local\Temp\pip-req-build-q3d_8t8e\opencv\modules\core\src\matrix.cpp:811: error: (-215:Assertion failed) 0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows in function 'cv::Mat::Mat'
The screenshot of error reporting is as follows
D:\Anaconda3\File\python.exe C:/Users/0moyi0/Desktop/DeepLearningExamples-master/hh.py
Traceback (most recent call last):
File "C:/Users/0moyi0/Desktop/DeepLearningExamples-master/hh.py", line 17, in <module>
normal_clone = cv2.seamlessClone(obj, im, mask, center, cv2.NORMAL_CLONE)
cv2.error: OpenCV(4.5.3) C:\Users\runneradmin\AppData\Local\Temp\pip-req-build-q3d_8t8e\opencv\modules\core\src\matrix.cpp:811: error: (-215:Assertion failed) 0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows in function 'cv::Mat::Mat'
I read the error report carefully It feels like a boundary error Feeling beyond the boundary
Then I tried to find the bug The path found in the prompt message cannot be found
Re analysis may be due to the wrong size in the parameters, resulting in the ROI area of the image exceeding the size of the image, i.e
0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows
Then I looked at the size of the two pictures carefully
First src.jpg What is the size of the 800 * 517
And then the size of dst.jpg is 800 * 449
Then you see the the mask part feels like it should be used in this place obj.shape Too big a mistake, and then replace it with im.shape, The bug has been found and solved. It can run normally
Modified code
# Pay attention to modify the path!
import cv2
import numpy as np
# Read images : src image will be cloned into dst
obj= cv2.imread("src.jpg")
im = cv2.imread("dst.jpg")
# Create an all white mask
mask = 255 * np.ones(im.shape, im.dtype)
# The location of the center of the src in the dst
width, height, channels = im.shape
center = (int(height/2), int(width/2))
# Seamlessly clone src into dst and put the results in output
normal_clone = cv2.seamlessClone(obj, im, mask, center, cv2.NORMAL_CLONE)
mixed_clone = cv2.seamlessClone(obj, im, mask, center, cv2.MIXED_CLONE)
# Write results
cv2.imwrite("normal.jpg", normal_clone)
cv2.imwrite("mixed.jpg", mixed_clone)
Screenshot of successful operation after modification
Normal.jpg generated successfully
and mixed.jpg
The parameters of this experiment are not set well, and will be modified later. I hope you can help with the same bug. Thank you