Tag Archives: python

Repo reports an error syntax error: invalid syntax

File "/mnt/fileroot/yuhua.lin/p/.repo/repo/main.py", line 79
    file=sys.stderr)
        ^
SyntaxError: invalid syntax

solve

This is because of the version of Python

mkdir -p ~/.bin
PATH="${HOME}/.bin:${PATH}"
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/.bin/repo
chmod a+rx ~/.bin/repo

Error in startup after the supervisor modifies the configuration file: error: cannot open an HTTP server: socket.error reported errno.eaddnotavail

 vim /etc/supervisord.conf

Modify the configuration file
remove the comments of the [inet_http_server] module
and modify the default IP, user name and password

after modification, reload the configuration file:

supervisorctl reload

At this time, it is found that the supervisor service has stopped, systemctl status supervisor View Status:

this is generally an error in the configuration file:
note that the local address is not filled in after the port, such as 47.xxx.xxx.xxx , which refers to who can access the server’s supervisor. If it is not filled in, everyone can access it. For example, it can be directly changed to port =: 9001 , and then reload.

 supervisorctl reload
 systemctl start supervisord

If it is set that everyone can access, you can log in to the browser:

I layhill successfully solved the problem through the above methods. Please correct the deficiencies!

Python Error: Process finished with exit code -1073740791 (0xC0000409)

Case 1 is also the case of more on-line): (graphics card) insufficient memory

At this time, we can adjust the memory in pycharm:
Press Shift + Ctrl + A to search for

where:
XMS in xms128m refers to the memory required for program startup, 128M is the size
xmx1011m in Xmx, Xmx refers to the memory required for program running, 1011m is the size
increase it. Of course, your hardware should be able to withstand this setting

Pyexcel Error: xlrd.biffh.XLRDError: Excel xlsx file; not supported

Phenomenon:

code

# content is a table data of byte type
sheet = pyexcel.get_sheet(file_type='xlsx', file_content=content)

report errors

xlrd.biffh.XLRDError: Excel xlsx file; not supported

reason

The installed pyexcel package version is too old

pyexcel-xls==0.5.8
pyexcel==0.5.9.1
pyexcel-xlsx==0.5.6

Solution:

Updated version (latest version)

pyexcel==0.6.7
pyexcel-io==0.6.4
pyexcel-xls==0.6.2
pyexcel-xlsx==0.6.0

Django project running service reported an error NameError: name ‘OS’ is not defined

Existing problems:
after Django creates a new project, when running the service command “Python manage. Py runserver”, an error is reported: NameError: name ‘OS’ is not defined


Solution:
find the setting.py file in the new project path and add “import OS” to it

Note: the method to judge whether the project is successfully created is if something similar to“ http://127.0.0.1:8000/ ”The project address, and “the install worked successfully! Integrations!” is displayed in the browser.

Apktool back compilation error [How to Solve]

report errors

error: No resource identifier found for attribute 'XXX' in package 'XXX'

Solution:

Save the XML file to “ http://schemas.android.com/apk/res-auto " changed to " http://schemas.android.com/apk/lib/com.app.chasebank "

other

I directly used Android killer for back compilation. There were more than 10 errors at once. It was too troublesome to change one by one, so I simply wrote a python script:

import os
import re

file = "error.txt"

def change_content(file):
    if os.path.exists(file):
        with open(file) as f:
            content = f.read()
        if "http://schemas.android.com/apk/res-auto" in content:
            print(file+":已修复")
            content = content.replace("http://schemas.android.com/apk/res-auto","http://schemas.android.com/apk/lib/com.app.chasebank")
            with open(file,"w") as f:
                f.write(content)

with open(file,encoding='utf8') as f:
    data = f.read()

result = re.findall(">W: (.*?):\d+: error: No resource identifier found for attribute",data)
for file in result:
    change_content(file)

Copy the error to the error.txt file, and then run the script to modify the XML file directly.

Sometimes, such errors will appear in the back compilation. You may need to copy the errors again and then execute the script. That is to say, some errors are not reported because the previous errors have not been solved, and all such errors cannot be reported at one time.

How to Solve Pychart configuration import torch error

Pycharm configuration import torch report error Traceback
Error content error screenshot solution
Problem solved

Error content

Traceback (most recent call last):
File “”, line 1, in
File “D:\PyCharm Community Edition 2021.2.2\plugins\python-ce\helpers\pydev_pydev_bundle\pydev_import_hook.py”, line 21, in do_import
module = self._system_import(name, *args, **kwargs)
ModuleNotFoundError: No module named ‘torch’
Screenshot of error report
Image:
Solution:
File–>Settings

Python Interpreter

Click the ‘+’
Search torch
Choose install Package

Importing the torch again in the Python Console shows True

Done!

How to Solve DVA switches history to browserhistory Error

report errors:

Module not found: Can't resolve 'history/createBrowserHistory'

Solution:

// import createHistory from 'history/createBrowserHistory';
// Error: Cannot find module 'history/createBrowserHistory';

// Change to
import { createBrowserHistory  as createHistory} from 'history';

const app = dva({
  history: createHistory(),
});