- Best Python IDEs for Linux
- 1. Eric
- 2. Geany
- 3. PyCharm
- 4. Spyder
- 5. Thonny
- 6. Visual Studio Code
- 7. Bluefish
- Wrapping Up
- Пишем первую программу на Python в Linux
- 2. Using Python on Unix platforms¶
- 2.1. Getting and installing the latest version of Python¶
- 2.1.1. On Linux¶
- 2.1.2. On FreeBSD and OpenBSD¶
- 2.1.3. On OpenSolaris¶
- 2.2. Building Python¶
- 2.3. Python-related paths and files¶
- 2.4. Miscellaneous¶
- 2.5. Custom OpenSSL¶
Best Python IDEs for Linux
Looking to code Python on your Linux system? Here are the best IDEs you can use for Python programming in Linux desktop.
Python is a popular scripting language among Linux users. It is also used extensively in Artificial Intelligence and Machine Learning, some of the most popular buzzwords in computing. Running Python script in Linux takes just a command. However, for serious Python programming, an IDE is always a better choice. An IDE combines various tools for seamless development with a specific programming language. Generally, it contains a code editor with syntax highlighting, a compiler and/or interpreter, debugging tools and other features needed to work with the specific programming language. If you are learning Python and want to use an IDE to test things, I have compiled a list of them to help you.
Many other IDEs are available for Python in Linux, which you won’t find here. They work with Python2 only (which has been deprecated). Hence, I have omitted such options.
1. Eric
Eric is an open-source editor based on the Qt6 toolkit and is written in Python itself. Eric boasts a ton of features for Python and is a proper IDE. It supports downloadable plugins, which can further extend its capabilities. It also has an Integrated Python debugger, Interactive Python shell, and Integrated support for Python Package Management (pip), to name a few of the many features it provides. Go check out the extensive list of its features on its official website.
2. Geany
Geany is an open source IDE based on the GTK3 toolkit, which is small and lightweight. Being a lightweight application, it runs perfectly fine on every type of Linux distro no matter the desktop environment. It supports many programming languages, including Python. It also supports some plugins to extend its capabilities. Not to forget, Geany is almost one of the best Notepad++ alternatives for Linux.
3. PyCharm
PyCharm is one of the most popular and advanced Python IDEs developed by JetBrains. JetBrains is the organization behind some of the best IDEs like Android Studio and the programming language Kotlin used for Android development. It is an open-source application which is quite an extensive application compared to others in the list. An open-source community edition is available for free. Although, a paid version is also available with more features needed for professional development, which is a proprietary edition. It has a load of features specific to the Python language, as it is specially tailored for the same. You can check out all its features on the website and its paid version’s pricing.
4. Spyder
Spyder is an open-source IDE based on a Qt toolkit designed for scientific use. It has MATLAB (language and platform for data analysis) like features. Spyder, being built for Scientific and Engineering applications, has features with which analysis can be done graphically using histograms, graphs, etc. Scientific tools provided by Spyder can be somewhat similar to the paid tools available with PyCharm. And that’s not all, it also provides a VIM plugin for providing VIM keybindings support. Visit Spyder’s website for more information about its applications for scientists and engineers.
5. Thonny
Thonny is an open source Python IDE based on the Tk GUI toolkit. It is tailored for teaching Python to beginners. Even though it uses a different GUI toolkit, Thonny is incredibly lightweight and simple to use when compared to other IDEs. If you are a beginner, go for it for its simplicity and small-sized installation. You can explore its GitHub page to know more about it.
6. Visual Studio Code
Visual Studio Code is an open-source Electron-based application developed by Microsoft. The user experience is well-polished compared to most other options. It can be used for many programming languages. But, to use it for coding in Python, you need to grab the plugin that enables it. Once you install the plugin required, you can start writing code in Python and learn about issues through its debugger. Being an Electron-based application, some users may not like it for the extra overhead. But, it works fairly well! If you want to use Microsoft’s Visual Studio Code without all its telemetry, you can opt for VSCodium.
7. Bluefish
Bluefish is an open-source editor based on the GTK3 toolkit for web designers. However, being a very powerful editor, one can also use it to write code in Python. I did not find any way to execute the file in Bluefish, but it supports syntax highlighting. The development activity appears to be inactive since 2020. You can head on to its official website to know more.
Wrapping Up
One can arguably use any text editor which supports syntax highlighting for writing code in Python, e.g., Emacs and VIM also Notepadqq. But, in my opinion, using an IDE provides a more comfortable environment for coding as compared. Python has many applications, ranging from web development to artificial intelligence. Therefore, some IDEs can provide features specific to a particular application of Python, which may not be available in some IDEs. There is no good or bad IDE, as it all boils down to the thing you want to use Python for. Which IDE would you use for Python? Your suggestions are always welcome in the comments.
Пишем первую программу на Python в Linux
Python доступен практически в любом современном дистрибутиве Linux, поэтому тем, кто собирается написать свою первую программу на Python в Linux, установка никаких дополнительных программ не потребуется (в дальнейшем нам конечно понадобятся кое-какие дополнительные библиотеки Python, но мы обязательно разберем их установку).
Для написания своей первой программы на Python в Linux, просто запустите свой любимый Linux и следуйте шагам этого совета.
Для написания Python-программ можно использовать любой из текстовых редакторов (я буду рассматривать редактор vi/vim). Не пугайтесь, основное количество программистов не использует для написания простых (и не только!) программ какое-либо многофункциональное программное обеспечение (типа сред программирования и т.п.). Достаточно воспользоваться тем, что есть под рукой!
Давайте попробуем посмотреть наличие Python в вашем дистрибутиве Linux. Для этого выполните команду: which python и, в случае успеха, вы увидите что-то вроде этого:
Как видим, Python присутствует в нашей системе и это хороший знак для того, чтобы продолжить наши действия.
Создадим каталог, в котором мы будем практиковаться в написании программ на Python и назовем его testplace: mkdir testplace и перейдем в него, выполнив команду: cd ~/testplace
Теперь создадим текстовый файл first.py, который и будет нашей первой программой на Python. Выполните команду: touch first.py и посмотрим его наличие командой: ls он обязательно там должен появиться!
Обратите внимание, что расширение у созданного нами файла должно быть .py. Это расширение стандартно для программ на Python и вскоре вы увидите, что очень много программ на Python уже существуют в вашей системе (если у вас Linux/Unix).
Теперь приступаем к написанию кода нашей первой программы на Python.
Откроем созданный нами файл в редакторе vi/vim: vi first.py и впишем в него следующие строки: #!/usr/bin/python
# My first program on Python!
print «Hello World. »
Выйдем из файла с сохранением, выполнив: :wq .
Для того, чтобы выполнить написанную нами программу в Linux, нам необходимо назначить ей права на выполнение. Сделаем это командой: chmod x first.py
Пришло время попробовать запустить созданную нами нашу первую программу на Python. Выполните в командной строке: ./first.py и посмотрите на результат. Он должен быть таким:
Код нашей первой программы очень прост:
1 строка ( #!/usr/bin/python ) — мы указываем путь к интерпретатору. Этой строкой будут начинаться многие дальнейшие наши программы, поэтому введем это за правило.
2 строка ( # My first program on Python! ) — комментарий. Все комментарии начинаются со знака #. Заметьте, что предыдущая строка — не комментарий!
3 строка ( print «Hello World. « ) — это просто вывод на экран надписи «Hello World. «.
Мы с вами написали крайне примитивную программу, выводящую на экран всего лишь одну строку, но многие учебники по программированию начинаются именно с этой «программы». Это стандарт, с которого начинают все программисты. С него начали и мы.
В последующих статьях мы не будем разбирать то, как создать файл и как назначить ему права на выполнение, а будем разбирать код создаваемых программ и сам процесс их работы.
2. Using Python on Unix platforms¶
2.1. Getting and installing the latest version of Python¶
2.1.1. On Linux¶
Python comes preinstalled on most Linux distributions, and is available as a package on all others. However there are certain features you might want to use that are not available on your distro’s package. You can easily compile the latest version of Python from source.
In the event that Python doesn’t come preinstalled and isn’t in the repositories as well, you can easily make packages for your own distro. Have a look at the following links:
2.1.2. On FreeBSD and OpenBSD¶
pkg_add -r python pkg_add ftp://ftp.openbsd.org/pub/OpenBSD/4.2/packages//python-.tgz
pkg_add ftp://ftp.openbsd.org/pub/OpenBSD/4.2/packages/i386/python-2.5.1p2.tgz
2.1.3. On OpenSolaris¶
You can get Python from OpenCSW. Various versions of Python are available and can be installed with e.g. pkgutil -i python27 .
2.2. Building Python¶
If you want to compile CPython yourself, first thing you should do is get the source. You can download either the latest release’s source or just grab a fresh clone. (If you want to contribute patches, you will need a clone.)
The build process consists of the usual commands:
./configure make make install
Configuration options and caveats for specific Unix platforms are extensively documented in the README.rst file in the root of the Python source tree.
make install can overwrite or masquerade the python3 binary. make altinstall is therefore recommended instead of make install since it only installs exec_prefix /bin/python version .
2.3. Python-related paths and files¶
These are subject to difference depending on local installation conventions; prefix and exec_prefix are installation-dependent and should be interpreted as for GNU software; they may be the same.
For example, on most Linux systems, the default for both is /usr .
Recommended location of the interpreter.
prefix /lib/python version , exec_prefix /lib/python version
Recommended locations of the directories containing the standard modules.
prefix /include/python version , exec_prefix /include/python version
Recommended locations of the directories containing the include files needed for developing Python extensions and embedding the interpreter.
2.4. Miscellaneous¶
To easily use Python scripts on Unix, you need to make them executable, e.g. with
and put an appropriate Shebang line at the top of the script. A good choice is usually
which searches for the Python interpreter in the whole PATH . However, some Unices may not have the env command, so you may need to hardcode /usr/bin/python3 as the interpreter path.
To use shell commands in your Python scripts, look at the subprocess module.
2.5. Custom OpenSSL¶
- To use your vendor’s OpenSSL configuration and system trust store, locate the directory with openssl.cnf file or symlink in /etc . On most distribution the file is either in /etc/ssl or /etc/pki/tls . The directory should also contain a cert.pem file and/or a certs directory.
$ find /etc/ -name openssl.cnf -printf "%h\n" /etc/ssl
$ curl -O https://www.openssl.org/source/openssl-VERSION.tar.gz $ tar xzf openssl-VERSION $ pushd openssl-VERSION $ ./config \ --prefix=/usr/local/custom-openssl \ --libdir=lib \ --openssldir=/etc/ssl $ make -j1 depend $ make -j8 $ make install_sw $ popd
$ pushd python-3.x.x $ ./configure -C \ --with-openssl=/usr/local/custom-openssl \ --with-openssl-rpath=auto \ --prefix=/usr/local/python-3.x.x $ make -j8 $ make altinstall
Patch releases of OpenSSL have a backwards compatible ABI. You don’t need to recompile Python to update OpenSSL. It’s sufficient to replace the custom OpenSSL installation with a newer version.