In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the relevant knowledge of how to make the python script run directly under ubuntu, the content is detailed and easy to understand, the operation is simple and fast, and has a certain reference value, I believe you will have something to gain after reading this ubuntu how to make the python script run directly. Let's take a look.
Very simply, add the following sentence to 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 check it with which python3.
Then add executable permissions to the python script after executing chmod + x. / xxx.py
For example, here I am
Sudo chmod + x. / translate.py
Finally run. / translate.py
And then. Wrong report
-bash:. / translate.py: / usr/bin/ python 3 ^ m: interpreter error: there is no such file or directory
Why?
This is the source code I wrote under win7, which was later transmitted to ubuntu with winscp, so it caused a problem. The code written under dos, taken to linux, is incompatible.
Solution:
Sudo vim translate.py:set ff=unix
And then execute. / translate.py
Ok runs perfectly, but if you take a closer look, it doesn't seem perfect, because every time you have to change to the directory where the file is located to run. In order to use the program more effectively, we can connect translate.py to / usr/bin, or / usr/local/bin, and so on, in a directory configured with system environment variables.
Sudo ln-s / xxxx/xxxx/xxxx/translate.py / usr/local/bin/dict
/ xxxx/xxxx/xxxx/, which is the absolute path where translate.py is located
/ usr/local/bin/dict,dict is renamed after translate.py soft connection
Running effect
This is the end of the article on "how to make python scripts run directly under ubuntu". Thank you for reading! I believe that everyone has a certain understanding of the knowledge of "how to make python scripts run directly under ubuntu". If you want to learn more, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.