Python3 Incompatibility

Hi, I have found few exploits written in older versions of python like python2.7. When I try to run them sometimes I need to install package from pip. But even after installing package it don’t detect it. I can’t reinstall it as it says requirement satisfied. I think I need to install package specifically for older version. How to do it?

If you have python2 and python3, you need to install packages separately. There are a couple of ways to do it and it depends on how your system is configured.

Id start with trying python2 -m pip install PACKAGENAME and see if that works.

I tried the command you said as “python2 -m pip install impacket” but it says module not found: pip/pip3

I was able to install pip but I got this error then:

python2.7 -m pip install impacket 1 ⨯
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 Release process - pip documentation v23.1.dev0 pip 21.0 will remove support for this functionality.
Defaulting to user installation because normal site-packages is not writeable
Collecting impacket
Downloading impacket-0.9.22.tar.gz (1.4 MB)
|████████████████████████████████| 1.4 MB 1.2 MB/s
ERROR: Command errored out with exit status 1:
command: /usr/bin/python2.7 -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/tmp/pip-install-aHhqmh/impacket/setup.py’“'”‘; file=’“'”‘/tmp/pip-install-aHhqmh/impacket/setup.py’“'”‘;f=getattr(tokenize, ‘"’“‘open’”’“‘, open)(file);code=f.read().replace(’”‘"’\r\n’“'”‘, ‘"’"’\n’“'”‘);f.close();exec(compile(code, file, ‘"’“‘exec’”’"‘))’ egg_info --egg-base /tmp/pip-pip-egg-info-SfC5Dq
cwd: /tmp/pip-install-aHhqmh/impacket/
Complete output (10 lines):
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: ‘extras_require’
warnings.warn(msg)
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: ‘install_requires’
warnings.warn(msg)
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] …]
or: setup.py --help [cmd1 cmd2 …]
or: setup.py --help-commands
or: setup.py cmd --help

error: invalid command 'egg_info'
----------------------------------------

ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

@happykharoud said:

python2.7 -m pip install impacket

So it implies you use python2.7 for python2?

ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Googling this implies that the setuptools are out of date.

pip install --upgrade setuptools might help.

(assuming you run this as pip2 not pip3)