Tag Archives: python

NPM installs dependent packages and reports an error node gyp rebuild… Solution

Abnormal information

npm ERR! code 1
npm ERR! path D:\demo\node_modules\node-sass
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node scripts/build.js
npm ERR! Building: C:\Program Files\nodejs\node.exe D:\demo\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp verb cli [
npm ERR! gyp verb cli   'C:\\Program Files\\nodejs\\node.exe',
npm ERR! gyp verb cli   'D:\\demo\\node_modules\\node-gyp\\bin\\node-gyp.js',
npm ERR! gyp verb cli   'rebuild',
npm ERR! gyp verb cli   '--verbose',
npm ERR! gyp verb cli   '--libsass_ext=',
npm ERR! gyp verb cli   '--libsass_cflags=',
npm ERR! gyp verb cli   '--libsass_ldflags=',
npm ERR! gyp verb cli   '--libsass_library='
npm ERR! gyp verb cli ]
npm ERR! gyp info using [email protected]
npm ERR! gyp info using [email protected] | win32 | x64
npm ERR! gyp verb command rebuild []
npm ERR! gyp verb command clean []
npm ERR! gyp verb clean removing "build" directory
npm ERR! gyp verb command configure []
npm ERR! gyp verb check python checking for Python executable "python2" in the PATH
npm ERR! gyp verb `which` failed Error: not found: python2
npm ERR! gyp verb `which` failed     at getNotFoundError (D:\demo\node_modules\which\which.js:13:12)
npm ERR! gyp verb `which` failed     at F (D:\demo\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed     at E (D:\demo\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed     at D:\demo\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` failed     at D:\demo\node_modules\isexe\index.js:42:5
npm ERR! gyp verb `which` failed     at D:\demo\node_modules\isexe\windows.js:36:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:195:21)
npm ERR! gyp verb `which` failed  python2 Error: not found: python2
npm ERR! gyp verb `which` failed     at getNotFoundError (D:\demo\node_modules\which\which.js:13:12)
npm ERR! gyp verb `which` failed     at F (D:\demo\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed     at E (D:\demo\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed     at D:\demo\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` failed     at D:\demo\node_modules\isexe\index.js:42:5
npm ERR! gyp verb `which` failed     at D:\demo\node_modules\isexe\windows.js:36:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:195:21) {
npm ERR! gyp verb `which` failed   code: 'ENOENT'
npm ERR! gyp verb `which` failed }
npm ERR! gyp verb check python checking for Python executable "python" in the PATH
npm ERR! gyp verb `which` succeeded python C:\Users\Administrator\AppData\Local\Programs\Python\Python39\python.EXE
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Command failed: C:\Users\Administrator\AppData\Local\Programs\Python\Python39\python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[:3];
npm ERR! gyp ERR! stack   File "<string>", line 1
npm ERR! gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
npm ERR! gyp ERR! stack                       ^
npm ERR! gyp ERR! stack SyntaxError: invalid syntax
npm ERR! gyp ERR! stack
npm ERR! gyp ERR! stack     at ChildProcess.exithandler (node:child_process:326:12)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:394:28)
npm ERR! gyp ERR! stack     at maybeClose (node:internal/child_process:1067:16)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
npm ERR! gyp ERR! System Windows_NT 10.0.19042
npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "D:\\demo\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd D:\demo\node_modules\node-sass
npm ERR! gyp ERR! node -v v16.3.0
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok
npm ERR! Build failed with error code: 1

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Administrator\AppData\Local\npm-cache\_logs\2021-06-22T01_36_13_984Z-debug.log

Configure environment variables

This is to exclude path customization without permission

NODE_ PATH=D:\node_ global\node_ modules

Put the critical path forward in the path

Global install cnpm

npm config set registry http://registry.npm.taobao.org/
npm i cnpm

Install windows platform compilation environment

npm install -g node-gyp
npm install –global –production windows-build-tools

Change the node sass version in package.json

“Node sass”: “~ 4.12.0” changed to “node sass”: “v4.13.0”

Delete node under root directory_ Modules folder

Cnpm reinstall

cnpm i

GDAL Error: ERROR 1: PROJ [How to Solve]

Using GDAL, an error occurs suddenly:

ERROR 1: PROJ: createGeodeticReferenceFrame: Cannot find proj.db
ERROR 1: PROJ: proj_as_wkt: Cannot find proj.db
ERROR 1: PROJ: proj_create_from_wkt: Cannot find proj.db
ERROR 1: PROJ: createGeodeticReferenceFrame: Cannot find proj.db
ERROR 1: PROJ: pj_obj_create: Cannot find proj.db
ERROR 1: PROJ: proj_as_wkt: Cannot find proj.db
ERROR 1: PROJ: proj_create_from_wkt: Cannot find proj.db
ERROR 1: PROJ: proj_create_from_wkt: Cannot find proj.db
ERROR 1: PROJ: pj_obj_create: Cannot find proj.db
ERROR 1: PROJ: proj_as_wkt: Cannot find proj.db
ERROR 1: PROJ: proj_as_wkt: Cannot find proj.db
ERROR 1: PROJ: proj_create_from_wkt: Cannot find proj.db
ERROR 1: PROJ: proj_create_from_database: Cannot find proj.db

Solution:

Add these codes below at the header of your codes.

import os
os.environ['PROJ_LIB'] = r'D:\Anaconda3\envs\tf14\Library\share\proj'

[Solved] error: ROIAlign_cuda.cu(275): error: no instance of function template “THCCeilDiv“ matches

Resolve roialign_ Cuda.cu and roipool_ Cuda.cu compilation error (two problems encountered)

Error 1:

D:/python/frankmocap-master/frankmocap-master/detectors/hand_object_detector/lib/model/csrc/cuda/ROIAlign_cuda.cu(275): error: no instance of function template "THCCeilDiv" matches the argument list
            argument types are: (long long, long)

D:/python/frankmocap-master/frankmocap-master/detectors/hand_object_detector/lib/model/csrc/cuda/ROIAlign_cuda.cu(275): error: no instance of overloaded function "std::min" matches the argument list
            argument types are: (<error-type>, long)

D:/python/frankmocap-master/frankmocap-master/detectors/hand_object_detector/lib/model/csrc/cuda/ROIAlign_cuda.cu(320): error: no instance of function template "THCCeilDiv" matches the argument list
            argument types are: (int64_t, long)

D:/python/frankmocap-master/frankmocap-master/detectors/hand_object_detector/lib/model/csrc/cuda/ROIAlign_cuda.cu(320): error: no instance of overloaded function "std::min" matches the argument list
            argument types are: (<error-type>, long)

4 errors detected in the compilation of "C:/Users/18295/AppData/Local/Temp/tmpxft_00003514_00000000-10_ROIAlign_cuda.cpp1.ii"

Solution:

Modify maskscoring_ rcnn/maskrcnn_ benchmark/csrc/cuda/ROIAlign_ Cuda.culine 275:

//Original code: dim3 grid(std::min(THCCeilDiv(output_size, 512L), 4096L));
dim3 grid(std::min(((int)output_size + 512 -1)/512, 4096));

Mask scoring/maskrcnn benchmark/csrc/cuda/ROIAlign cuda.cu3203

//Original code: dim3 grid(std::min(THCCeilDiv(grad.numel(), 512L), 4096L));
dim3 grid(std::min(((int)(grad.numel()) + 512 -1)/512, 4096));

Modify maskscoring_rcnn/maskrcnn_benchmark/csrc/cuda/ROIPool_cuda.cu Line129:

// dim3 grid(std::min(THCCeilDiv(output_size, 512L), 4096L));
dim3 grid(std::min(((int)output_size + 512 -1)/512, 4096));

Modify maskscoring_rcnn/maskrcnn_benchmark/csrc/cuda/ROIPool_cuda.cu line 176:

//dim3 grid(std::min(THCCeilDiv(grad.numel(), 512L), 4096L));
dim3 grid(std::min(((int)(grad.numel()) + 512 -1)/512, 4096));

After modification, execute Python setup.py build development

Error 2:

error: ROIAlign_ Cuda.cu and roipool_ “In cuda.cu file”__ Floorf “and”__ Ceilf “error

error: calling a __host__ function("__floorf") from a __device__ 
function("get_coordinate_weight<float> ") is not allowed
error: identifier "__floorf" is undefined in device code

error: calling a __host__ function("__ceilf") from a __global__ 
function("detectron2::RoIAlignRotatedForward<float> ") is not allowed
error: identifier "__ceilf" is undefined in device code

Solution:

Find roialign_ Cuda.cu and roipool_ Cuda.cu file, add F after ceil and floor , that is, ceil is changed to ceilf , floor is changed to floor
the successful implementation is as follows:

[Solved] RuntimeError: run loop already started raise RuntimeError(‘run loop already started‘)

RuntimeError: run loop already started raise RuntimeError(‘run loop already started’)
Error Codes:

self.engine.say(content)
self.engine.runAndWait()
self.engine.stop()

Error message

raise RuntimeError('run loop already started')
RuntimeError: run loop already started

Solution:

self.engine.say(content)
self.engine.runAndWait()
self.engine.endLoop()   # add this line
self.engine.stop()

[Solved] error: unrecognized arguments: –multiprocessing-fork

Problem description

Using pyinstaller to package the project into an executable file, we encountered the above problems after solving various problems. The project we wrote needs to use multiple processes, but this problem will occur if the process is not successfully created.

Solution 1

I think others’ solutions are as follows:

if __name__ == '__main__':
	# The following sentence must be added below the if
	multiprocessing.freeze_support()

Solution 2

The general search answer is scheme 1, but this does not apply to me. As a result, the problem bothered me for two days. Just realized that if you use argparse in your code, package it into an executable file, and use multiple processes, you are likely to report this error. After I modified argparse and packaged it into an executable file, multiple processes can be started normally.

[Solved] Run sudo python setup.py install Error: error: error in setup.cfg: command ‘build‘ has no such option ‘i18

1. Problem description

Error: error in setup.cfg: Command ‘build’ has no such option ‘I18N’ when running sudo Python setup.py install in the installation package of Ubuntu system

2. Solutions

Other dependent environments need to be installed:

Python distutils extra needs to be installed

sudo apt-get update -y
sudo apt-get install -y python-distutils-extra

Then run it again

sudo python setup.py install

[Solved] cv2.error: OpenCV(4.5.3) :-1: error: (-5:Bad argument) in function “pointPolygonTest“

python   Running error: CV2. Error: opencv (4.5.3): – 1: error: (- 5: bad argument) in function “pointpolygontest”

The solution is simple because the CV2 version is not compatible

Step 1: uninstall the installed version

Step 2: install the old version

Step 3:   Confirm successful installation

The above error will not be reported during operation.

RuntimeError: CUDNN_STATUS_EXECUTION_FAILED [How to Solve]

The error is as follows:

Traceback (most recent call last):
  File "main.py", line 23, in <module>
    t.train()
  File "c:\Paper Code\RCAN-master-Real\RCAN_TrainCode\code\trainer.py", line 51, in train
    sr = self.model(lr, idx_scale)
  File "C:\Anaconda3\envs\pytorch0.4.0\lib\site-packages\torch\nn\modules\module.py", line 491, in __call__
    result = self.forward(*input, **kwargs)
  File "c:\Paper Code\RCAN-master-Real\RCAN_TrainCode\code\model\__init__.py", line 54, in forward
    return self.model(x)
  File "C:\Anaconda3\envs\pytorch0.4.0\lib\site-packages\torch\nn\modules\module.py", line 491, in __call__
    result = self.forward(*input, **kwargs)
  File "c:\Paper Code\RCAN-master-Real\RCAN_TrainCode\code\model\rcan.py", line 107, in forward
    x = self.sub_mean(x)
  File "C:\Anaconda3\envs\pytorch0.4.0\lib\site-packages\torch\nn\modules\module.py", line 491, in __call__
    result = self.forward(*input, **kwargs)
  File "C:\Anaconda3\envs\pytorch0.4.0\lib\site-packages\torch\nn\modules\conv.py", line 301, in forward
    self.padding, self.dilation, self.groups)
RuntimeError: CUDNN_STATUS_EXECUTION_FAILED

Before code modification:

if __name__ == '__main__':
    torch.manual_seed(args.seed)
    checkpoint = utility.checkpoint(args)

    if checkpoint.ok:
        loader = data.Data(args)
        model = model.Model(args, checkpoint)
        loss = loss.Loss(args, checkpoint) if not args.test_only else None
        t = Trainer(args, loader, model, loss, checkpoint)
        while not t.terminate():
            t.train()
            t.test()

        checkpoint.done()

After code modification

if __name__ == '__main__':
    torch.backends.cudnn.enabled = False
    torch.manual_seed(args.seed)
    checkpoint = utility.checkpoint(args)

    if checkpoint.ok:
        loader = data.Data(args)
        model = model.Model(args, checkpoint)
        loss = loss.Loss(args, checkpoint) if not args.test_only else None
        t = Trainer(args, loader, model, loss, checkpoint)
        while not t.terminate():
            t.train()
            t.test()

        checkpoint.done()

Running ~ ~

cv2 error – function not implemented [How to Solve]

Run target detection, import CV2   Normal, CV2. Write() is OK, but CV2. Imshow() has an error: function not implemented, prompting windows and Ubuntu to install libgtk2.0-dev and PKG config, re run cmake

PIP install opencv Python runs unresponsive.

Recall that Anaconda was installed later and uninstalled first. Sure enough, the original opencv relied on Python 3.8 of Ubuntu 20.04.

uninstall  After installation, reinstall install and everything is normal.

python cx_Oracle.DatabaseError: Error while trying to retrieve text for error ORA-01804

Problem Description:

Using Python package CX_ When setting scheduled tasks on the Oracle server, errors are always reported, such as the title, but running alone is no problem

resolvent:

Under the guidance of the boss, add a few lines of code in front of the script to solve the problem perfectly. The environment variable path is configured according to its own path.

import os

os.environ["ORACLE_HOME"] = '/home/oracle/app/oracle/product/11.2.0/dbhome_1'
os.environ["ORACLE_BASE"] = '/home/oracle/app/oracle'
os.environ["ORACLE_SID"] = 'orcl'
os.environ["LD_LIBRARY_PATH"] = '/home/oracle/app/oracle/product/11.2.0/dbhome_1/lib:/lib:/usr/lib'

fatal error: Python.h: No such file or directory

fatal error: Python.h: No such file or directory

Process: through PIP install a library, an error occurred and the python. H header file could not be found

Solution

Search stackoverflow. My environment is CentOS, so execute sudo Yum install python3 devel and then go to the PIP install library. It’s all OK

For apt (Ubuntu, Debian…):

sudo apt-get install python-dev   # for python2.x installs
sudo apt-get install python3-dev  # for python3.x installs

For yum (CentOS, RHEL…):

sudo yum install python-devel    # for python2.x installs
sudo yum install python3-devel   # for python3.x installs

For dnf (Fedora…):

sudo dnf install python2-devel  # for python2.x installs
sudo dnf install python3-devel  # for python3.x installs

For zippers (openSUSE):

sudo zypper in python-devel   # for python2.x installs
sudo zypper in python3-devel  # for python3.x installs

For apk (Alpine…):
This is a departure from the normal Alpine naming
scheme, which uses py2- and py3- prefixes

sudo apk add python2-dev  # for python2.x installs
sudo apk add python3-dev  # for python3.x installs

For apt-cyg (Cygwin…):

apt-cyg install python-devel   # for python2.x installs
apt-cyg install python3-devel  # for python3.x installs

RuntimeError: Address already in use [How to Solve]

(cp3) zhangrui@test:~/project/cp3/CenterPoint$ python -m torch.distributed.launch --nproc_per_node=4 ./tools/train.py ~/project/cp3/CenterPoint/work_dirs/voxsc_centerpoint_voxelnet_0075voxel_fix_bn_z.py
*****************************************
Setting OMP_NUM_THREADS environment variable for each process to be 1 in default, to avoid your system being overloaded, please further tune the variable forformance in your application as needed.
*****************************************
No Tensorflow
No Tensorflow
Traceback (most recent call last):
  File "./tools/train.py", line 137, in <module>
    main()
  File "./tools/train.py", line 86, in main
    torch.distributed.init_process_group(backend="nccl", init_method="env://")
  File "/home/zhangrui/anaconda3/envs/cp3/lib/python3.7/site-packages/torch/distributed/distributed_c10d.py", line 436, in init_process_group
    store, rank, world_size = next(rendezvous_iterator)
  File "/home/zhangrui/anaconda3/envs/cp3/lib/python3.7/site-packages/torch/distributed/rendezvous.py", line 179, in _env_rendezvous_handler
    store = TCPStore(master_addr, master_port, world_size, start_daemon, timeout)
RuntimeError: Address already in use

The TCP port is occupied. Start multiple jobs on one computer. You need to specify a different port for each job (29500 by default) to avoid communication conflict
the solution is to specify the port while running the program, and give the port number arbitrarily before the PY file to be executed:

python -m torch.distributed.launch --nproc_per_node=1 --master_port 66660  ./tools/train.py ~/project/cp3/CenterPoint/work_dirs/voxel_config/nusc_centerpoint_voxelnet_0075voxel_fix_bn_z.py

Another way is to find the occupied port number (insert print output in the program), then find the PID value corresponding to the port number: netstat – nltp, and then cancel the occupation of the port through kill – 9 PID.