简体   繁体   中英

Can't install packages like simpleHTTPServer with pip2.7

I'm trying to install a module called simpleHTTPServer but can't do so as described below:

root@kali:~# pip install simpleHTTPServer
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python2.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.
ERROR: Could not find a version that satisfies the requirement simpleHTTPServer (from versions: none)
ERROR: No matching distribution found for simpleHTTPServer
root@kali:~#

I've screwed up my python2.7 a few hours ago by accidentally removing (rm) the python2.7 file in /usr/bin instead of renaming it with mv because i didn't pay attention to what i was doing. So I removed everything that had to do with python2.7. I've then managed to download python 2.7.18 from the official site and executed these commands below AS ROOT:

cd /home/johnmap007/Downloads/Python-2.7.18
./configure
make
make install
python setup.py clean
python setup.py build
python setup.py install

Then I got back up and running. pip started to work ok and python gives me the interpreter when i execute it in the cmd line. I am running Kali Linux by the way. I tried installing other packages like scapy and they worked. I don't know why i can't install this specific package. Any help would be greatly appreciated. Thanks in advance!

EDIT: For some reason, as i was running apt upgrade, i got errors about python2.7 not being configured the right way:

Setting up python2.7 (2.7.18-1) ...
/var/lib/dpkg/info/python2.7.postinst: 9: /usr/bin/python2.7: not found
dpkg: error processing package python2.7 (--configure):
 installed python2.7 package post-installation script subprocess returned error exit status 127
Setting up sqlmap (1.4.11-1) ...
Installing new version of config file /etc/sqlmap/sqlmap.conf ...
Setting up libgstreamer-plugins-base1.0-0:amd64 (1.18.1-1) ...
Setting up libgstreamer-plugins-base1.0-0:i386 (1.18.1-1) ...
dpkg: dependency problems prevent configuration of python2:
 python2 depends on python2.7 (>= 2.7.18~); however:
  Package python2.7 is not configured yet.

dpkg: error processing package python2 (--configure):
 dependency problems - leaving unconfigured
Setting up seclists (2020.4-0kali1) ...
Setting up libgstreamer-gl1.0-0:amd64 (1.18.1-1) ...
Setting up gstreamer1.0-plugins-base:amd64 (1.18.1-1) ...
Setting up gstreamer1.0-plugins-base:i386 (1.18.1-1) ...
Setting up python3-cryptography (3.2.1-1) ...
Setting up libsvn1:amd64 (1.14.0-3) ...
dpkg: dependency problems prevent configuration of python2.7-dev:
 python2.7-dev depends on python2.7 (= 2.7.18-1); however:
  Package python2.7 is not configured yet.

dpkg: error processing package python2.7-dev (--configure):
 dependency problems - leaving unconfigured
Setting up gstreamer1.0-gl:amd64 (1.18.1-1) ...
Setting up gstreamer1.0-x:amd64 (1.18.1-1) ...
Setting up gstreamer1.0-x:i386 (1.18.1-1) ...
Setting up gstreamer1.0-alsa:amd64 (1.18.1-1) ...
dpkg: dependency problems prevent configuration of python2-dev:
 python2-dev depends on python2 (= 2.7.18-2); however:
  Package python2 is not configured yet.
 python2-dev depends on python2.7-dev (>= 2.7.18~); however:
  Package python2.7-dev is not configured yet.

dpkg: error processing package python2-dev (--configure):
 dependency problems - leaving unconfigured
Setting up gir1.2-gst-plugins-base-1.0:amd64 (1.18.1-1) ...
Setting up subversion (1.14.0-3) ...
Processing triggers for kali-menu (2020.4.0) ...
Processing triggers for libc-bin (2.31-4) ...
Processing triggers for man-db (2.9.3-2) ...
Errors were encountered while processing:
 python2.7
 python2
 python2.7-dev
 python2-dev
needrestart is being skipped since dpkg has failed
E: Sub-process /usr/bin/dpkg returned an error code (1)

I have no idea what happened and i tried running dpkg --configure -a already. Can someone help me please?

That's in the standard library, so you don't need to install anything

https://docs.python.org/2/library/simplehttpserver.html

You can start it with

python -m SimpleHTTPServer

But you should use Python3, anyway, where it's renamed

python3 -m http.server 

I removed everything that had to do with python2.7

You're modifying operating system files at that point, and Kali Linux uses Python for more than your own scripting purposes. But based on /usr/bin/python2.7: not found , you could start symlink-ing files around to fix at least that error

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM