- Установить Python в Linux
- Проверка установки Python в Linux
- Установка с помощью менеджера пакетов
- Скачать и установить Python 2.7.9
- Скачать и установить Python 3.9.1
- pyenv: установка нескольких разных версий
- Установка Pip
- How install python on kali linux
- Keeping backwards compatibility in Kali
- Frequently Asked Questions
- I have downloaded a Python script, what should I do?
- How can I get rid of the login message?
- I have a Python 2 script that doesn’t run, what should I do?
- I want pip for Python 2, how can I get it back?
- I wrote a Python script, what should I do?
- How to Install Anaconda Python on Kali Linux
- Anaconda Python Kali Linux Installation Guide
- 1. Launching Console
- Install Python3 in Kali Linux
- Installing Python 3 on Linux¶
- Working with Python 3¶
- Setuptools & Pip¶
- Pipenv & Virtual Environments¶
- O’Reilly Book
Установить Python в Linux
Проверка установки Python в Linux
Прежде чем приступать к решительным действиям желательно проверить не установлен ли Python в Вашем дистрибутиве Linux по умолчанию.
Как Вы можете увидеть — в моём Debian из коробки установлены Python 2.7.16 и Python 3.7.3
Если у вас нет Python по умолчанию — переходите к следующему шагу.
Прежде чем устанавливать Python советую установить бибилотеки для работы с ssl.
Иначе, в будущем можно столкнуться с ошибкой SSL module is not available
Установка с помощью менеджера пакетов
Самый простой способ — воспользоваться менеджером пакетов.
В Debian , Ubuntu и других .deb дистрибутивах это apt
В CentOS , RedHat и других .rpm дистрибутивах это yum
sudo apt update
sudo apt-get install python3
sudo yum update -y
sudo yum install python3
Если что-то не получается — переходите к следующему шагу
Скачать и установить Python 2.7.9
Чтобы установить Python из скачанного архива нужен компилятор C например gcc
Если нужно установить второй Python последней версии 2.7.9
—2021-01-11 12:17:43— https://www.python.org/ftp/python/2.7.9/Python-2.7.9.tgz Resolving www.python.org (www.python.org). 151.101.84.223, 2a04:4e42:14::223 Connecting to www.python.org (www.python.org)|151.101.84.223|:443. connected. HTTP request sent, awaiting response. 200 OK Length: 16657930 (16M) [application/octet-stream] Saving to: ‘Python-2.7.9.tgz’ Python-2.7.9.tgz 100%[=============================================================>] 15.89M 3.63MB/s in 4.4s 2021-01-11 12:17:48 (3.61 MB/s) — ‘Python-2.7.9.tgz’ saved [16657930/16657930]
Распаковать архив можно командой
tar xvzf Python-2.7.9.tgz
Затем нужно перейти в распакованную директорию и выполнить configure make install
cd Python-2.7.9
./configure
make
sudo make install
Скачать и установить Python 3.9.1
Перед установкой Python 3 советую установить библиотеку libffi
sudo apt-get install libffi-dev
Она далеко не всегда нужна, но если понадобится и её нет — придётся переустанавливать Python
wget https://www.python.org/ftp/python/3.9.1/Python-3.9.1.tgz ; tar xvzf Python-3.9.1.tgz ; cd Python-3.9.1 ; ./configure ; sudo make install
pyenv: установка нескольких разных версий
Про установку разных версий python на одну систему, управление этими версиями и виртуальными окружениями в них — читайте статью pyenv
Установка Pip
sudo apt update
sudo apt install python3-pip
pip3 —version
pip 18.1 from /usr/lib/python3/dist-packages/pip (python 3.7)
Библиотеки лежат в /home/andrei/.local/lib
ls -la /home/andrei/.local/lib
total 0
drwx—— 0 andrei andrei 512 Mar 20 16:41 .
drwx—— 0 andrei andrei 512 Mar 19 13:31 ..
drwx—— 0 andrei andrei 512 Mar 19 13:19 python2.7
drwx—— 0 andrei andrei 512 Mar 20 15:01 python3.5
Источник
How install python on kali linux
Kali Linux fully switched to Python 3. This means that any tool packaged by Kali that was using Python 2 has been either dropped or converted to use Python 3. Any tool converted to Python 3 contains only scripts with /usr/bin/python3 as their shebang.
Concerning the packages that come straight from Debian, they did the same on most packages, but there are a few exceptions where packages are allowed to continue to rely on Python 2. However those packages have been updated so that all their scripts use /usr/bin/python2 as their shebang and so that they depend on the python2 binary package (instead of the former python ).
Thanks to those changes, Debian no longer need to provide /usr/bin/python and recent upgrades will effectively get rid of that symlink.
Unfortunately, when you download a Python script on the web, it will likely have /usr/bin/python as its shebang. If you try to execute it without fixing the shebang line, you will end up with an error like this one:
In Debian, you can reinstate the /usr/bin/python symlink by installing:
- python-is-python2 if you want to have it point to python2
- python-is-python3 if you want to have it point to python3
Keeping backwards compatibility in Kali
Given the large number of users that would not know how to avoid the above error, we decided that Kali would continue to ship Python 2 by default (as long as Debian still provides it) and that /usr/bin/python would point to it. We are also keeping a few common external modules (like requests ) so that random exploit scripts have a reasonable chance to run successfully.
Howewer, pip for Python2 (aka python-pip) is gone, /usr/bin/pip is the same as /usr/bin/pip3 and it will install modules for Python 3. See the FAQ below for more information.
This compatibility has been implemented by having kali-linux-headless recommend python2 , python-is-python2 and offsec-awae-python2 so that they are installed by default while being removable by users that would like to get rid of them.
To make users aware of this situation, we are displaying a promiment message on login:
The hope is that they will read this article and know how do deal with the various issues that they will encounter.
Frequently Asked Questions
I have downloaded a Python script, what should I do?
You need to inspect its shebang line. The shebang line is the first line of a script and it starts with #! followed by the path of the interpreter that will be used to execute the script.
If the interpreter is /usr/bin/python , you should read the documentation to see whether the script can run with Python 3. If yes, then you should update the shebang line to point to /usr/bin/python3 . Otherwise you should update it to point to /usr/bin/python2 .
Good shebang lines that can be kept:
- #!/usr/bin/python3
- #!/usr/bin/python2
- #!/usr/bin/env python3
- #!/usr/bin/env python2
Bad shebang lines that need to be updated:
How can I get rid of the login message?
The message will only be displayed as long as /usr/bin/python points to the deprecated Python 2. Now that you know about this situation and that you know how to fix the shebang line of old scripts, you can safely get rid of /usr/bin/python :
Or you can decide to make it point to Python 3:
Either of those actions will get rid of the login message.
Alternatively, if you want to keep /usr/bin/python pointing to python2 and you still want to disable the message, you can do this:
I have a Python 2 script that doesn’t run, what should I do?
If your Python 2 script uses modules that are not among those that we ship in the offsec-awae-python2 compatibility package (see list here), then you can try pyenv to setup a fully isolated Python 2 environment where you can use pip to install supplementary modules. See our Using EoL Python versions on Kali article.
I want pip for Python 2, how can I get it back?
I wrote a Python script, what should I do?
Be nice with end users:
- document clearly whether your code runs with Python 3 or Python 2
- use /usr/bin/python3 or /usr/bin/python2 as the shebang line, it’s more expressive than /usr/bin/python and is more likely to have the desired result
- update it for Python 3 compatibility if that’s not the case yet
Updated on: 2021-Sep-27
Author: rhertzog
Источник
How to Install Anaconda Python on Kali Linux
Anaconda Python Kali Linux Installation Guide
You are Welcome! The Tutorial Shows You Step-by-Step How to Install Anaconda Python 2/3 in Kali GNU/Linux Desktop.
And Anaconda Python for Kali Linux is a Free, Easy-to-Install Package Manager, Environment Manager and Python Distribution with a Collection of 1,000+ Open Source Packages with Free Community Support.
Furthermore, Anaconda includes the most Awesome Scientific Packages:
- NumPy : N-dimensional array for numerical computation
- SciPy : Scientific computing library for Python
- Matplotlib : 2D Plotting library for Python
- Pandas : Powerful Python data structures
and data analysis toolkit - Seaborn : Statistical graphics library for Python
- Bokeh : Interactive web visualization library
- Scikit-Learn : Python modules for machine learning and data mining
- NLTK : Natural language toolkit
- Jupyter Notebook : Web app that allows you to create and share
documents that contain live code, equations,
visualizations and explanatory text - R essentials : R with 80+ of the most used R packages for data science
Finally, this guide includes instructions on How to Getting-Started with Anaconda Python on Kali Linux Linux.
1. Launching Console
Open a Shell Terminal emulator window
(Press “Enter” to Execute Commands)
Источник
Install Python3 in Kali Linux
Install Python3 in Kali Linux |
We don’t need to install Python3 in recent updated and full-upgraded Kali Linux. Because Kali Linux 2019.1 is comes with Python 3.6 pre-installed. But if we have older version of Kali Then.
Installing Python3 is very easy. We need to go to the Download section of official Python website.
Download Section of https://www.python.org/ |
Now we click on Download Python 3.x.x (As of this writing, the latest is Python 3.7.4) and download the tar.xz compressed file. After finishing the download we open the Terminal window is our Kali Linux system.
We will run a command to check the updates
After updating (if available) we need to go to the Downloads section by using following command:
Then we type following command:
Here 3.x.x. is representing our downloaded recent version of Python
The screenshot is following:
Now we got a decompressed folder of Pyhton3.x.x (whenever we wright Python3.x.x the x.x will represents the downloaded version of Python3 for us that is Python 3.7.4).
Now we go to the folder Python3.x.x by applying following command :
Then we need to configure the Python3 before install. So we configure it by using following command:
The screenshot is following:
Then we need to run make to compile the Python source before install.
It will take a little time. The screenshot is following:
Then we can install Python3.x.x by using following command:
This will take time. So sit back and share our this post to friends.
When this process will complete we will check the version of python3 by using following command:
The following screenshot shows that we have Python version 3.7.4.
When we need to use Python 2 we just type python in Kali Linux terminal and when we need Python 3 we type python3 in our Kali Linux system.
Python 3.6 is pre-installed in newer Kali Linux system. But by default pip3 is not there to install pip3 run following command :
Источник
Installing Python 3 on Linux¶
This document describes how to install Python 3.6 or 3.8 on Ubuntu Linux machines.
To see which version of Python 3 you have installed, open a command prompt and run
If you are using Ubuntu 16.10 or newer, then you can easily install Python 3.6 with the following commands:
If you’re using another version of Ubuntu (e.g. the latest LTS release) or you want to use a more current Python, we recommend using the deadsnakes PPA to install Python 3.8:
If you are using other Linux distribution, chances are you already have Python 3 pre-installed as well. If not, use your distribution’s package manager. For example on Fedora, you would use dnf :
Note that if the version of the python3 package is not recent enough for you, there may be ways of installing more recent versions as well, depending on you distribution. For example installing the python3.9 package on Fedora 32 to get Python 3.9. If you are a Fedora user, you might want to read about multiple Python versions available in Fedora.
Working with Python 3¶
At this point, you may have system Python 2.7 available as well.
This might launch the Python 2 interpreter.
This will always launch the Python 3 interpreter.
Setuptools & Pip¶
The two most crucial third-party Python packages are setuptools and pip.
Once installed, you can download, install and uninstall any compliant Python software product with a single command. It also enables you to add this network installation capability to your own Python software with very little work.
Python 2.7.9 and later (on the python2 series), and Python 3.4 and later include pip by default.
To see if pip is installed, open a command prompt and run
To install pip, follow the official pip installation guide — this will automatically install the latest version of setuptools.
Note that on some Linux distributions including Ubuntu and Fedora the pip command is meant for Python 2, while the pip3 command is meant for Python 3.
However, when using virtual environments (described below), you don’t need to care about that.
Pipenv & Virtual Environments¶
The next step is to install Pipenv, so you can install dependencies and manage virtual environments.
A Virtual Environment is a tool to keep the dependencies required by different projects in separate places, by creating virtual Python environments for them. It solves the “Project X depends on version 1.x but, Project Y needs 4.x” dilemma, and keeps your global site-packages directory clean and manageable.
For example, you can work on a project which requires Django 1.10 while also maintaining a project which requires Django 1.8.
This page is a remixed version of another guide, which is available under the same license.
This opinionated guide exists to provide both novice and expert Python developers a best practice handbook to the installation, configuration, and usage of Python on a daily basis.
O’Reilly Book
This guide is now available in tangible book form!
All proceeds are being directly donated to the DjangoGirls organization.
Источник