


How to solve the error when opening terminal using python under linux
May 02, 2023 pm 05:43 PMWhen using python to open the terminal under linux, an error occurs
Scenario 1: Execute automated tasks on jenkins, use the jenkins user (with sudo permissions) when executing test tasks, and the test script is in linux When executing (background), an error occurs when the following code is executed:
os.system(f"/usr/bin/konsole -e {cmd_orin2_10s}")
Scenario 2: There is no problem with the test script being executed locally. When executing locally, the root user can be used and the command window can be opened normally
Error log:
17:44:03 qt.qpa.xcb: could not connect to display 17:44:03 qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found. 17:44:03 This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem. 17:44:03 17:44:03 Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, xcb.
Solution:
It can be compared from scenario 1 and scenario 2, it should be caused by environment variables cause. To find the problem from the environment variables and the displayed window, you can find export DISPLAY=":0.0"
Supplement: pycharm runs without problems but the terminal (terminal) runs various modules. Problem
Problem Description
Many times you are used to using pycharm and have everything done, but you ignore many path problems. Occasionally, you need to interact with other environments and platforms. For example, if you write a C# program to call python, it is equivalent to passing parameters to the terminal to start. At this time, various No module problems will be displayed. The reason is because the external environment calls the python interface. , you have to look for each module in your program, but if these modules have not been added to the environment variables, they will not be found. Therefore, it is recommended to use the following statement at the front of each py file used
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/../')
This operation can add the entire upper-level directory of the current file to the environment variable, so that all files under the upper-level directory can be easily called
If you have many directory levels and the current directory is in a deep location, then you can slightly change this command to include all the files and directories you want to use, such as Yes
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/../../')
Of course if you just want to call all directories under the current folder, then you can use
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + './')
The above is the detailed content of How to solve the error when opening terminal using python under linux. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Pythoncanbeoptimizedformemory-boundoperationsbyreducingoverheadthroughgenerators,efficientdatastructures,andmanagingobjectlifetimes.First,usegeneratorsinsteadofliststoprocesslargedatasetsoneitematatime,avoidingloadingeverythingintomemory.Second,choos

pandas.melt() is used to convert wide format data into long format. The answer is to define new column names by specifying id_vars retain the identification column, value_vars select the column to be melted, var_name and value_name, 1.id_vars='Name' means that the Name column remains unchanged, 2.value_vars=['Math','English','Science'] specifies the column to be melted, 3.var_name='Subject' sets the new column name of the original column name, 4.value_name='Score' sets the new column name of the original value, and finally generates three columns including Name, Subject and Score.

Install pyodbc: Use the pipinstallpyodbc command to install the library; 2. Connect SQLServer: Use the connection string containing DRIVER, SERVER, DATABASE, UID/PWD or Trusted_Connection through the pyodbc.connect() method, and support SQL authentication or Windows authentication respectively; 3. Check the installed driver: Run pyodbc.drivers() and filter the driver name containing 'SQLServer' to ensure that the correct driver name is used such as 'ODBCDriver17 for SQLServer'; 4. Key parameters of the connection string

First, define a ContactForm form containing name, mailbox and message fields; 2. In the view, the form submission is processed by judging the POST request, and after verification is passed, cleaned_data is obtained and the response is returned, otherwise the empty form will be rendered; 3. In the template, use {{form.as_p}} to render the field and add {%csrf_token%} to prevent CSRF attacks; 4. Configure URL routing to point /contact/ to the contact_view view; use ModelForm to directly associate the model to achieve data storage. DjangoForms implements integrated processing of data verification, HTML rendering and error prompts, which is suitable for rapid development of safe form functions.

Windowsisbetterforbeginnersduetoeaseofuse,seamlesshardwarecompatibility,andsupportformainstreamsoftwarelikeMicrosoftOfficeandAdobeapps.2.LinuxoutperformsWindowsonolderorlow-resourcehardwarewithfasterboottimes,lowersystemrequirements,andlessbloat.3.Li

Install Git: Install Git through the package manager on the server and verify the version; 2. Create a dedicated Git user: Use adduser to create a git user and optionally restrict its shell access; 3. Configure developer SSH access: Set the .ssh directory and authorized_keys file for git users, and add the developer's public key; 4. Create a bare repository: Initialize the bare repository on the server and set correct ownership; 5. Client cloning and push: Developer cloning the repository through SSH, submit changes and successfully push code to complete the construction of a private Git server.

Introduction to Statistical Arbitrage Statistical Arbitrage is a trading method that captures price mismatch in the financial market based on mathematical models. Its core philosophy stems from mean regression, that is, asset prices may deviate from long-term trends in the short term, but will eventually return to their historical average. Traders use statistical methods to analyze the correlation between assets and look for portfolios that usually change synchronously. When the price relationship of these assets is abnormally deviated, arbitrage opportunities arise. In the cryptocurrency market, statistical arbitrage is particularly prevalent, mainly due to the inefficiency and drastic fluctuations of the market itself. Unlike traditional financial markets, cryptocurrencies operate around the clock and their prices are highly susceptible to breaking news, social media sentiment and technology upgrades. This constant price fluctuation frequently creates pricing bias and provides arbitrageurs with

Biopython is an important Python library for processing biological data in bioinformatics, which provides rich functions to improve development efficiency. The installation method is simple, you can complete the installation using pipinstallbiopython. After importing the Bio module, you can quickly parse common sequence formats such as FASTA files. Seq objects support manipulation of DNA, RNA and protein sequences such as inversion complementarity and translation into protein sequences. Through Bio.Entrez, you can access the NCBI database and obtain GenBank data, but you need to set up your email address. In addition, Biopython supports pairwise sequence alignment and PDB file parsing, which is suitable for structural analysis tasks.
