0

Virtual env

I want to create virtual env for Python2 to use tools thar were written in Python2 (Volatilty2, Iodine, and perhaps some other later on).

I have errors but, the virtual env seems to be working.

Modules

I will need to use some modules. I can install some such as request. But I can't install some other such as scappy.

Virtual env

I would like to create a virtual environnement to use some tools written in Python2 on my Kali fully updated and upgraded.

To do so, I use the following command and get the output:

┌──(e1k㉿kali)-[~/test]
└─$ virtualenv -p /usr/bin/python2.7 venv
fail
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/virtualenv/seed/embed/via_app_data/via_app_data.py", line 82, in _get
    result = get_wheel(
  File "/usr/lib/python3/dist-packages/virtualenv/seed/wheels/acquire.py", line 23, in get_wheel
    wheel = from_bundle(distribution, version, for_py_version, search_dirs, app_data, do_periodic_update, env)
  File "/usr/lib/python3/dist-packages/virtualenv/seed/wheels/bundle.py", line 11, in from_bundle
    wheel = load_embed_wheel(app_data, distribution, for_py_version, of_version)
  File "/usr/lib/python3/dist-packages/virtualenv/seed/wheels/bundle.py", line 30, in load_embed_wheel
    wheel = get_embed_wheel(distribution, for_py_version)
  File "/usr/lib/python3/dist-packages/virtualenv/seed/wheels/embed/__init__.py", line 76, in get_embed_wheel
    raise Exception((
Exception: Wheel for pip for Python 2.7 is unavailable. apt install python2-pip-whl
fail
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/virtualenv/seed/embed/via_app_data/via_app_data.py", line 82, in _get
    result = get_wheel(
  File "/usr/lib/python3/dist-packages/virtualenv/seed/wheels/acquire.py", line 23, in get_wheel
    wheel = from_bundle(distribution, version, for_py_version, search_dirs, app_data, do_periodic_update, env)
  File "/usr/lib/python3/dist-packages/virtualenv/seed/wheels/bundle.py", line 11, in from_bundle
    wheel = load_embed_wheel(app_data, distribution, for_py_version, of_version)
  File "/usr/lib/python3/dist-packages/virtualenv/seed/wheels/bundle.py", line 30, in load_embed_wheel
    wheel = get_embed_wheel(distribution, for_py_version)
  File "/usr/lib/python3/dist-packages/virtualenv/seed/wheels/embed/__init__.py", line 76, in get_embed_wheel
    raise Exception((
Exception: Wheel for setuptools for Python 2.7 is unavailable. apt install python2-setuptools-whl
fail
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/virtualenv/seed/embed/via_app_data/via_app_data.py", line 82, in _get
    result = get_wheel(
  File "/usr/lib/python3/dist-packages/virtualenv/seed/wheels/acquire.py", line 23, in get_wheel
    wheel = from_bundle(distribution, version, for_py_version, search_dirs, app_data, do_periodic_update, env)
  File "/usr/lib/python3/dist-packages/virtualenv/seed/wheels/bundle.py", line 11, in from_bundle
    wheel = load_embed_wheel(app_data, distribution, for_py_version, of_version)
  File "/usr/lib/python3/dist-packages/virtualenv/seed/wheels/bundle.py", line 30, in load_embed_wheel
    wheel = get_embed_wheel(distribution, for_py_version)
  File "/usr/lib/python3/dist-packages/virtualenv/seed/wheels/embed/__init__.py", line 76, in get_embed_wheel
    raise Exception((
Exception: Wheel for wheel for Python 2.7 is unavailable. apt install python2-wheel-whl
created virtual environment CPython2.7.18.final.0-64 in 5013ms
  creator CPython2Posix(dest=/home/e1k/test/venv, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/e1k/.local/share/virtualenv)
    added seed packages: pip==20.3.4, setuptools==44.1.1, wheel==0.37.1
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator

So I tried to install the packages : python2-pip-whl, python2-setuptools-whl, python2-wheel-whl

┌──(e1k㉿kali)-[~/test]
└─$ sudo apt install python2-pip-whl python2-setuptools-whl python2-wheel-whl
Lecture des listes de paquets... Fait
Construction de l'arbre des dépendances... Fait
Lecture des informations d'état... Fait      
Aucune version du paquet python2-pip-whl n'est disponible, mais il existe dans la base
de données. Cela signifie en général que le paquet est manquant, qu'il est devenu obsolète
ou qu'il n'est disponible que sur une autre source

Aucune version du paquet python2-wheel-whl n'est disponible, mais il existe dans la base
de données. Cela signifie en général que le paquet est manquant, qu'il est devenu obsolète
ou qu'il n'est disponible que sur une autre source

E: Le paquet « python2-pip-whl » n'a pas de version susceptible d'être installée
E: Le paquet « python2-wheel-whl » n'a pas de version susceptible d'être installée

Thoose packages are not available, and I'm not sure that they are really needed for create a virtual env because my virutal env have been created and I can activate it. And start python :

┌──(e1k㉿kali)-[~/test]
└─$ source venv/bin/activate
                                                                                                                                                                                                                                   
┌──(venv)─(e1k㉿kali)-[~/test]
└─$ python              
Python 2.7.18 (default, Aug  1 2022, 06:23:55) 
[GCC 12.1.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 

So it seems to be working perfectly.

So why did I have errors ? And how can I correct it ?

Modules

Now I want to install some modules, so I first check my pip version :

┌──(venv)─(e1k㉿kali)-[~/test]
└─$ pip -V                                                                     
pip 20.3.4 from /home/e1k/test/venv/lib/python2.7/site-packages/pip (python 2.7)

And then I install request and use it :

┌──(venv)─(e1k㉿kali)-[~/test]
└─$ pip install requests  
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Collecting requests
  Downloading requests-2.27.1-py2.py3-none-any.whl (63 kB)
     |████████████████████████████████| 63 kB 1.2 MB/s 
Collecting idna<3,>=2.5; python_version < "3"
  Downloading idna-2.10-py2.py3-none-any.whl (58 kB)
     |████████████████████████████████| 58 kB 3.9 MB/s 
Collecting chardet<5,>=3.0.2; python_version < "3"
  Downloading chardet-4.0.0-py2.py3-none-any.whl (178 kB)
     |████████████████████████████████| 178 kB 6.4 MB/s 
Collecting urllib3<1.27,>=1.21.1
  Downloading urllib3-1.26.12-py2.py3-none-any.whl (140 kB)
     |████████████████████████████████| 140 kB 7.8 MB/s 
Collecting certifi>=2017.4.17
  Downloading certifi-2021.10.8-py2.py3-none-any.whl (149 kB)
     |████████████████████████████████| 149 kB 8.5 MB/s 
Installing collected packages: idna, chardet, urllib3, certifi, requests
Successfully installed certifi-2021.10.8 chardet-4.0.0 idna-2.10 requests-2.27.1 urllib3-1.26.12
                                                                                                                                                                                                                                   
┌──(venv)─(e1k㉿kali)-[~/test]
└─$ python              
Python 2.7.18 (default, Aug  1 2022, 06:23:55) 
[GCC 12.1.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> r = requests.get("http://pratique.leparisien.fr/glossaire/informatique/ordinateur/http-1330003116")
>>> r.status_code
200

And my module is install here :

┌──(venv)─(e1k㉿kali)-[~/test]
└─$ pip show requests
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.                                                                    
Name: requests
Version: 2.27.1
Summary: Python HTTP for Humans.
Home-page: https://requests.readthedocs.io
Author: Kenneth Reitz
Author-email: me@kennethreitz.org
License: Apache 2.0
Location: /home/e1k/test/venv/lib/python2.7/site-packages
Requires: idna, chardet, urllib3, certifi
Required-by: 

But when I want to use some other packages such as scapy, I get the following error :

┌──(venv)─(e1k㉿kali)-[~/test]
└─$ python                        
Python 2.7.18 (default, Aug  1 2022, 06:23:55) 
[GCC 12.1.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import scapy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named scapy
>>> import scapy.all
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named scapy.all
>>> 

But I have scapy install on my Kali. When I put scapy on my terminal it works fine.

And when I tried to use it with Python3, it also works perfectly

┌──(e1k㉿kali)-[~]
└─$ python3       
Python 3.10.8 (main, Oct 24 2022, 10:07:16) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import scapy.all
>>> 

I tried to look over the Internet but didn't find anything about my error on virtual env and how to correct it.

I neither find how to use scapy with python2 on a virtual env.

Edit 1 :

I try to install PyCrypto on the same Virtual env and i get the following error.

This means that I have an issue with the wheel package.

 ERROR: Command errored out with exit status 1:
   command: /home/e1k/test/venv/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-dx1Og2/pycrypto/setup.py'"'"'; __file__='"'"'/tmp/pip-install-dx1Og2/pycrypto/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-ZHc8Jz                                             
       cwd: /tmp/pip-install-dx1Og2/pycrypto/ 

So I definitley have an issue the setup of Python. But I don't know at all how can I solve it.

Does someone have an idea ?

Thanks.

e1k
  • 9
  • 3

0 Answers0