Let’s take the translation program as an example. Last time, I talked to you about application packaging under Windows. This time, I will tell you that Python files can be executed by themselves under Linux, so there is no need for python xxx.py. It's very simple, just add the following sentence at the top of the Python source file! #!/usr/bin/python3 /usr/bin/python3 is the directory where the python3 interpreter is located under Ubuntu. You can use which python3 to view it. Then execute chmod +x ./xxx.py to add executable permissions to the Python script For example, here sudo chmod +x ./translate.py Finally run ./translate.py Then... an error was reported -bash: ./translate.py: /usr/bin/python3^M: interpreter error: no such file or directory Why? This is the source code I wrote under Win7, and then transferred it to Ubuntu using WinSCP. This caused a problem: the code written under DOS is incompatible with Linux. Solution: sudo vim translate.py :set ff=unix Then execute ./translate.py OK, it runs perfectly, but if you look closely, it seems not perfect, because every time you have to switch to the directory where the file is located to run it, in order to use the program more conveniently, we can connect translate.py to /usr/bin, or /usr/local/bin, etc., in the directory where the system environment variables are configured. sudo ln -s /xxxx/xxxx/xxxx/translate.py /usr/local/bin/dict /xxxx/xxxx/xxxx/ is the absolute path where translate.py is located /usr/local/bin/dict, dict is the name of translate.py after soft linking Operation effect OK, won’t there be a ready-made translation program in my Ubuntu system from now on? Isn’t it wonderful! The above method of implementing Python scripts to run directly under Ubuntu is all the content that the editor shares with you. I hope it can give you a reference, and I also hope that you will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Why do select @@session.tx_read_only appear in DB in large quantities?
>>: How to implement real-time polygon refraction with threejs
Delayed loading (lazy loading) and preloading are...
Description of the phenomenon: The project uses s...
First, let me explain that what we want to do is ...
1. From father to son Define the props field in t...
Today, I set up a newly purchased Alibaba Cloud E...
When server B (172.17.166.11) is powered on or re...
Preface This article introduces how to use the ne...
This is a test of the interviewee's basic kno...
Quoting Baidu's explanation of pseudo-static:...
When searching online for methods to install MySQ...
There are many form elements. Here is a brief sum...
1. Command Introduction time is used to count the...
This article shares the detailed steps of install...
Looking at a website is actually like evaluating a...
Today I helped a classmate solve a problem - Tomc...