• Home
  • |
  • blog

  • |
  • Surprisingly troubled Python e...

Surprisingly troubled Python environment construction, what are the options?

Written By notebooktabletphone

My name is Manabu Terada and I am an advisor to the Association for the Promotion of Python Engineer Development (hereafter referred to as the Association). I am in a position to formulate exam questions and collaborate with the community. For beginners, I think that it is a place to worry about what to code and how to move it. So this time I would like to talk about version selection and editors.

■What version of Python should I use?

Python is upgraded every October. Currently 3.9 is the latest version, and 3.10 will be released in October this year. However, unless you want to use a very new function, there is no need to rush to respond, and we often start upgrading when it can be used stably (about 1 year). For that reason, 3.8 is still in use today, and it seems that 3.9 will be fine soon, so we are gradually migrating to 3.9. Then, the reasons for not immediately upgrading to the new version are as follows.

Although new functions may be added, basically the previous functions can be used as they are, and it is unlikely that the program will not work. In fact, when I upgraded from 3.8 to 3.9, almost no code changed.

Version upgrades often change internal API structures, often breaking third-party packages. Also, it is unclear whether the wheel downloaded during pip installation is compatible with the new version or has been tested, so I will put it on hold until they are clarified. As an actual example, after migrating to 3.9, the case of Jupyter Lab not working on Windows continued for a while. In addition, depending on the environment, new versions may not be supported, such as the version that can be used with AWS Lambda is 3.8.

Because security support is provided for 5 years, you can use it without worry.

There are cases where the OS itself requires Python, but in many cases those OSes have not been completely migrated to Python 3. The representative is macOS, and 2.7 starts when Python is launched. However, Python 2 will reach its end of life in January 2020, so it's definitely best not to use it anymore. Also, Python 2 and 3 are fundamentally incompatible, so something written in Python 2 may not run in Python 3. The correction points are fixed, so there is nothing that cannot be fixed, but it is not enough to be used until it is fixed. There are many things that only experienced people can understand. For those reasons, Python 2 should not be your choice.

■How to develop

The next step is the development environment. Many people who have been developing for a long time continue to use the familiar development environment, and there are many options. I hope you can find something that suits your taste. You can choose between two ways to enter the code itself: interactive mode or an editor.

Surprisingly worried Python environment construction, choices What?

It is used when creating a script system, when creating a web system using a framework, or when creating a program module. Mainly used by developers.

It is often used to check/experiment the behavior of Python. It is often used in learning and by data scientists.

It is one of the official Python installation methods, and refers to the one in the state as it is without any customization. Recently, it has become easier to introduce libraries in the data science field, and more and more people are making this choice. There are some things that are not supported or difficult to configure to your liking. The official installer distributed on Python.org is recommended because it is easier to receive support. * What is distributed on Python.org is created by the corporation that operates Python.org called Python Software Foundation (PSF). By the way, vanilla is taken from vanilla soft cream. It means a standard one with nothing in it.

Because data science packages are grouped together, it is gaining popularity, especially for data scientists and educational institutions. Normally, in a development environment, you use the pip command to install what you need, but Anaconda does it all at once, so it's easy and convenient. This is a distribution made by a company called Anaconda, so the policy depends on the intention of the company. In fact, Anaconda's licensing system has recently become more complex, such as charging for large-scale commercial use. These changes are likely to continue in the future and should be used with caution. In my personal opinion, in addition to the high possibility of revision of the license fee, since it is developed only by Anaconda and is closed to the Anaconda community, it must be resolved within that culture. It is not recommended to use it because there are many parts that should not be used.

You can run Python etc. on a web browser, and it is done interactively. It looks like an experiment notebook and is used when writing a little bit of code for an experiment. In addition, it is often used by data scientists, and there are also cases where the work created in Notebook is submitted to the customer as a deliverable. Some people close the world only here because they can do data analysis and machine learning.

It is provided as an integrated development environment for Python and can be used in an interactive mode, but it is basically used as an editor. When it comes to full-scale development, there are things that are lacking in functionality, so developers often move to other tools, making it suitable for beginners to use for learning.

A Python editor provided by JetBrains, which provides editors for PHP, Java, and Ruby. There are free and paid versions (approximately 10,000 yen for the first year for individuals, price reductions for continued use, for companies). I have. Those who use it firmly use the paid version. When I talk to various people, they often mention this PyCharm or VSCode, which I will introduce next.

It's a free editor from Microsoft that comes with a variety of add-ons, and the ecosystem is booming these days as more and more people use VS Code. With functional enhancements that are made each time, Docker compatibility and Git integration are now possible, and more and more things are completed with VS Code.

By the way, Python has a coding convention called PEP8 (how to write spaces and parentheses, etc.). It is a guideline to make it easy for everyone to read, and it is desirable to write in a way that matches this as much as possible, but I think there are many aspects that are difficult for beginners. In such a case, I think it is possible to use a tool called Black that forcibly changes the format. This Black is a so-called "Ore-sama tool" that forcibly corrects the code as if there is no room for discussion, but it is very convenient because it automatically adds spaces even if you forget to put them. When it first started being used, there were pros and cons, but the recent trend in the community is that it can't be helped if Mr. Black says so. By going through the formatter, you don't have to think about extra things, so you can learn efficiently. It is possible to put it in VS Code with a simple setting.

■Lastly

Personally, I'm not very good at customizing when building an environment, so I'm the type of person who enjoys setting up an environment just by pressing a button. VS Code is good at that kind of thing, and the recommended library is displayed, and you can easily set up a suitable environment just by pressing it.

There is no end to the controversy over editors, as editor wars by professional engineers often unfold. Actually, I settled with PyCharm about 5 or 6 years ago, but it was VS Code that hit it. It can be said that I saw the seriousness of Microsoft, and I think that many professional engineers are using it now. I used to use VS Code for JavaScript and PyCharm for Python. PyCharm itself has many good points, so I will continue to have the paid version.

So far, I have tried various environments, but due to the rapid evolution of technology, there is no choice but to change at a pace of about once every few years, and there is nothing that can be used for 5 to 10 years. That said, I definitely think it's better to have an editor that fits in your hand. Some people are still using Emacs, so if it's something you're comfortable with, it's good to keep using it, and if you're dissatisfied, I think it's good to find something new. Next time, I would like to talk about the environment to operate.

The latest information of our association can be found on the official website or on the official Facebook page. We also post news related to Python on our Facebook page, so please follow us. Also, on the YouTube channel "Python Engineer Certification Examination", I talk about the exam outline and study tips, and comment videos from those who have passed. Please also take a look.

[PR] Provided by: Python Engineer Development Promotion Association