Installing python kali linux

Installing python 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

Источник

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 :

Читайте также:  Linux как присвоить значение переменной

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 :

Источник

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)

Источник

Установить 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]

Читайте также:  Установка php mac os big sur

Распаковать архив можно командой

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

Источник

Как обновить все пакеты Python в Kali Linux

В вашей системе Kali Linux полно устаревших пакетов Python. Вы можете убедиться в этом сами, для вывода пакетов Python 3, для которых выпущена новая версия:

Для вывода пакетов Python 2, для которых выпущена новая версия:

Чтобы обновить сразу все пакеты Python 3 в Kali Linux выполните команду:

Чтобы обновить сразу все пакеты Python 2 в Kali Linux выполните команду:

Ошибки pip при обновлении пакетов Python 3

Но если говорить точнее, то обновится большинство пакетов — некоторые не обновятся из-за разных ошибок и предупреждений.

Пример предупреждения, когда отсутствует необходимая зависимость:

python-debianbts 2.7.3 requires pysimplesoap!=1.16.2, which is not installed.

То есть пакету python-debianbts требуется pysimplesoap, который не установлен. Решение проблемы — просто устанавливаем отсутствующую зависимость командой вида:

Если проблема с пакетом для Python 2, то используем соответствующую версию pip:

Когда установите все зависимости, ещё раз запустите команду из первого сообщения для повторной установки пакетов, которые не смогли обновиться.

Пример другого предупреждения, в котором упоминается distutils:

Cannot uninstall ‘AdvancedHTTPServer’. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

В сообщении сказано, что не получается удалить AdvancedHTTPServer, поскольку он является частью установленного distutils и невозможно точно определить, какие файлы принадлежат ему.

Можно просто пропустить обновления этих пакетов — то есть ничего не делать.

При желании обновить и эти пакеты, то используйте опцию —ignore-installed в команде вида:

Например, для обновления AdvancedHTTPServer:

Если пакет предназначен для Python2, то используйте pip2:

Также у меня возникло несколько других ошибок, в основном при сборке пакетов из-за отсутствия необходимых файлов. Причина чаще всего в том, что не установлена необходимая зависимость (разные заголовки для компиляции). Такие ошибки нужно решать в индивидуальном порядке — смотреть, какого файла не хватает, искать какому пакету он принадлежит, устанавливать этот пакет и заново запускать обновление.

Например:

Говорит о том, что pkg-config не найден, устанавливаем его:

Источник

Оцените статью