Tag Archives: pride

[Solved] UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring it

UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring it

After installing anaconda, there will report an error when you import some module in ipython:

UserWarning: mkl-service package failed to import, therefore Intel® MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured. Please install mkl-service package

 

Solution:
First configure three environment variables, one is missing
E:\Anaconda3
E:\Anaconda3\Scripts
E:\Anaconda3\Library\bin
Put E:\Anaconda3\Library\bin under
libcrypto-1_1-x64.dll
libssl-1_1-x64.dll
Copy the above two files to
E:\Anaconda3\DLLs
OK, you can restart pycharm and it will work

[Solved] wxauto error: ImportError: DLL load failed while importing win32gui: Can’t find the specified program

Background

Using wxauto to develop wechat robot, there was an error when running the program in Pycharm

Error prompt

Traceback (most recent call last):
  File "D:\Project\wechatBot\test.py", line 2, in <module>
    from wxauto import WeChat
  File "C:\Users\pokeu\anaconda3\envs\wechatbot\lib\site-packages\wxauto\__init__.py", line 2, in <module>
    from .wxauto import WxParam, WxUtils, WeChat, COPYDICT
  File "C:\Users\pokeu\anaconda3\envs\wechatbot\lib\site-packages\wxauto\wxauto.py", line 10, in <module>
    import win32gui, win32con
ImportError: DLL load failed while importing win32gui: Can't find the specified program.

Solution:

Check if the win32gui.pyd file exists in the C:\Users\username\anaconda3\envs\wechatbot\Lib\site-packages\win32 directory

If not, run pip install pywin32 to install it.

Add C:\Users\username\anaconda3\envs\wechatbot\Lib\site-packages\pywin32_system32 to the system environment variable.

Notes.
a. User name Replace with your own user name.
b. The first half of C:\Users\username\anaconda3 is the installation path of anaconda, replace it with your own.
c. \envs\wechatbot is the path of the new environment I created (wechatbot), replace it with your own environment, or ignore it if you didn’t create it, and just find \Lib\site-packages\win32.

In the original import … import the following library before the original import …: import pywintypes, e.g.

import pywintypes
#import pythoncom # Uncomment this if some other DLL load will fail
from wxauto import WeChat
import time, random

Now run the program again, and there should be no error.

[Solved] weditor Plug-in Dump Hierarchy Error: Local server not started, start with $ python -m weditor

I had tried many solutions online. but they do not work. here is my working solution I found finally.

 

Solution:

1. First, make sure that ADB devices can query your device

2. Key solution: delete ATX on the mobile phone and re-execute python -m uiautomator2 init

3. Just in case, don’t directly execute the WebEditor. Be sure to execute python -m weditor

Then click Dump Hierarchy to synchronize the screen. Don’t use real-time, just use static.

Python3.7 Capture exception error: Too broad exception clause

In Pycharm, using try…exception will result in the Too broad exception clause… warning

The reason for this error is that the exceptions caught in the past are generalized and not to specific exceptions, which lack relevance and can be solved by specifying the exact exception type.
such as:

Baseexception: the base class of all exceptions
systemexit: the interpreter requests to exit
keyboardinterrupt: the user interrupts execution (usually input ^c)

error: base class of general error
stopiteration: the iterator has no more values
generatorexit: the generator has an exception to notify the exit
standarderror: base class of all built-in standard exceptions
arithmeticerror: base class of all numerical calculation errors
floatingpointerror: floating-point calculation error
overflowerror: numerical operation exceeds the maximum limit
zerodivisionerror: division (or modulo) Zero (all data types)
assertionerror: assertion statement failure
attributeerror: the object does not have this attribute
eofilter: there is no built-in input, Reaching EOF tag
environmenterror: base class of operating system error
ioerror: input/output operation failure
oserror: operating system error
windowserror: system call failure
importerror: import module/object failure
lookuperror: base class of invalid data query
indexerror: this index is not in the sequence
keyerror: this key is not in the mapping
memoryerror: memory overflow error (not fatal for Python interpreter)
nameerror: undeclared/initialized object (no attributes)
unboundlocalerror: accessing uninitialized local variables
referenceerror: weak reference Trying to access an object that has been garbage collected
runtimeerror: general runtime error
notimplementederror: unimplemented method
syntaxerror: Python syntax error
indentationerror: indentation error
taberror: mixed use of tab and space
systemerror: general interpreter system error
typeerror: invalid operation on type
valueerror: passing in invalid parameters
Unicode error: Unicode related Error of
Unicode decodeerror: error in Unicode decoding
Unicode encodeerror: error in Unicode encoding
Unicode translateerror: error in Unicode conversion
warning: base class of warning
deprecationwarning: warning about deprecated features
futurewarning: warning about future semantic changes in construction
overflowwarning: old warning about automatic promotion to long integer (long) Warning of
pendingdeprecationwarning: warning about feature will be discarded
runtimewarning: warning about suspicious runtime behavior
syntaxwarning: warning about suspicious syntax
userwarning: warning generated by user code

If you are not sure about the possible errors, or you need to use exception and pycharm is not allowed to complain, how should you solve it
Method 1: turn off the option to detect exceptions in code detection in the compiler
Method 2: add # noinspection PyBroadException before the try statement

# noinspection PyBroadException
try:
       pass
except Exception as e:
       pass

[Solved] PyCharm pytest-html Install Error: Try to run this command from the system terminal. Make sure that you use

PyCharm pytest-html Install Error: Try to run this command from the system terminal. Make sure that you use

Exception prompt:
try to run this command from the system terminal Make sure that you use the correct version of ‘pip’ installed for your Python interpreter located at ‘E:\python\Program\Scripts\python.exe’.

Solution:
Switch the pycharm interpreter and reconfigure it again.

How to Solve word2vec Module Error: AttributeError & UnicodeDecodeError

1. Decode Issues
1. Error Messages: UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xd7 in position 1
2. Error Codes:

Insert # -*- coding: utf8 -*-

def write_review(review, stop_words_address, stop_address, no_stop_address):
    """Write out the processed data"""
    no_stop_review = remove_stop_words(review, stop_words_address)
    with open(no_stop_address, 'a') as f:
        for row in no_stop_review:
            f.write(row[-1])
            f.write("\n")
    f.close()


if __name__ == '__main__':
    segment_text = cut_words('audito_whole.csv')
    review_text = remove_punctuation(segment_text)
    write_review(review_text, 'stop_words.txt', 'no_stop.txt', 'stop.txt')

    # Model Training Master Program
    logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO)
    sentences_1 = word2vec.LineSentence('no_stop.txt')
    model_1 = word2vec.Word2Vec(sentences_1)

    # model.wv.save_word2vec_format('test_01.model.txt', 'test_01.vocab.txt', binary=False)  # 保存模型,后面可直接调用
    # model = word2vec.Word2Vec.load("test_01.model")  # Calling the model

    # Calculate the list of related words for a word
    a_1 = model_1.wv.most_similar(u"Kongjian", topn=20)
    print(a_1)

    # Calculate the correlation of two words
    b_1 = model_1.wv.similarity(u"Kongjian", u"Houzuo")
    print(b_1)

3. Error parsing: this error means that the character encoded as 0xd7 cannot be parsed during decoding. This is because the encoding method is not specified when saving the text, so the GBK encoding may be used when saving the text
4. Solution: when writing out the data, point out that the coding format is UTF-8, as shown in the following figure

def write_review(review, stop_words_address, stop_address, no_stop_address):
    """Write out the processed data"""
    with open(stop_address, 'a', encoding='utf-8') as f:
        for row in review:
            f.write(row[-1])
            f.write("\n")
    f.close()

    no_stop_review = remove_stop_words(review, stop_words_address)
    with open(no_stop_address, 'a', encoding='utf-8') as f:
        for row in no_stop_review:
            f.write(row[-1])
            f.write("\n")
    f.close()

5. Expansion – why did this mistake happen
first of all, we click the source code file of the error report, as shown in the following figure:
open utils, and we find the following code

it can be seen that the encoding format set by word2vec is UTF-8. If it is not UTF-8 during decoding, errors = ‘strict’ will be triggered, and then UnicodeDecodeError will be reported

2. Attribute error
1 Error reporting: attributeerror: ‘word2vec’ object has no attribute ‘most_similar’
2. Wrong source code:

 # Model Training Master Program
    logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO)
    sentences_1 = word2vec.LineSentence('no_stop.txt')
    model_1 = word2vec.Word2Vec(sentences_1)

    # model.wv.save_word2vec_format('test_01.model.txt', 'test_01.vocab.txt', binary=False)  # 保存模型,后面可直接调用
    # model = word2vec.Word2Vec.load("test_01.model")  # Calling the model

    # Calculate the list of related words for a word
    a_1 = model_1.most_similar(u"Kongjian", topn=20)
    print(a_1)

**3. Analysis of error reports: * * error reports refer to attribute errors because the source code structure has been updated in the new word2vec. See the official website for instructions as follows:

**4. Solution: * * replace the called object as follows:

 # Model Training Master Program
    logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO)
    sentences_1 = word2vec.LineSentence('no_stop.txt')
    model_1 = word2vec.Word2Vec(sentences_1)

    # model.wv.save_word2vec_format('test_01.model.txt', 'test_01.vocab.txt', binary=False)  # 保存模型,后面可直接调用
    # model = word2vec.Word2Vec.load("test_01.model")  # Calling the model

    # Calculate the list of related words for a word
    a_1 = model_1.wv.most_similar(u"Kongjian", topn=20)
    print(a_1)

5. Why is model_1.wv.most_similar(), I didn’t find the statement about WV definition in word2vec. Does anyone know?

[Solved] XiaoMi Phone Uiautomator Startup Error: uiautomator2.GatewayError

check the error messages:

OSError: [WinError adb shell am instrument -w -r -e debug false -e class com.github.uiautomator.stub.Stub com.github.uiautomator.test/android.support.test.runner.AndroidJUnitRunner] uiautomator2.GatewayError(gateway error, time used 0.0s): 'https://github.com/openatx/uiautomator2/wiki/Common-issues'

It is said that app-uiautomator.apk or app-uiautomator-test.apk not installed. but if you use the following command:

 python -m uiautomator2 init

There are no errors, and you can see the successful installation of the above two apps, so the problem is not the failure of uiautomator app installation.

Solution:

Turn on the settings of Xiaomi mobile phone – turn on developer options – turn on USB debugging – turn on USB installation – turn on USB debugging (security settings) – turn on the application that passes USB verification (default on) – turn on wireless display authentication (optional). The key option is not to enable MIUI optimization. After operating the above settings, execute python -m uiautomator2 init (no error), and then you can execute the relevant scripts

[Solved] Neo4j error: Import-Module & neo4j Neo.ClientError.Security.Unauthorized

Error reporting record

1. Import module: failed to load the specified module. Solution:

Solution: find the neo4j PS1 file in the bin directory, open it, find the import module, and change the relative path to the absolute path, that is,

"D:\Neo4j\neo4j-community-3.5.25\bin\Neo4j-Management.psd1"

2. When changing the password, neo4j Neo.ClientError.Security.Unauthorized

Solution: open neo4j.conf in the conf folder and delete the comment in front of #dbms.security.auth_enabled=false

[Solved] Pychart breakpoint error: frames are not available

Today when I use pycharm again, the problem of frames are not available after setting the menu bar File->Settings->Editor->File Encodings

 

Modify Project Encodind to UTF-8, but still not, then menu bar File->Settings->Build,Execution,Deployment->Python Debugger

 

I unchecked PyQt compatible, but it didn’t work. Finally, I hit a few more breakpoints on the code to solve the problem.

[Solved] pip Fatal error in launcher: Unable to create process using

Problem scenario

When we moved the python folder, the system’s global variables are still the original python path, at this time in cmd, type python, the system will follow the previous path to find python.exe, pip.exe. so you need to modify the global variables. But many friends then modify the global variables, although python is available, but pip still can not be used, will report the error pip Fatal error in launcher: Unable to create process using {original pip path} {now pip path}.

Problem analysis

This is because pip is actually python code, pip inside the python interpreter path or the original path is not updated, modify the system global variables and will not affect the python path in the pip.exe file.

Problem-solving:

The brute force solution is to directly modify the python path inside pip.exe. Note that pip.exe is a binary file and cannot be modified directly.

1. Download and open binary software (WinHex, hedit)

2. Modify and save the file

Modify and save directly on the right