Unable to install pip using python on unix - centos

I'm trying to install pip module for python using the command python ./get-pip.py -v but it returns an error that zlib is not available:
[root#centos1 yum.repos.d]# python ./get-pip.py -v
Traceback (most recent call last):
File "./get-pip.py", line 19177, in <module>
main()
File "./get-pip.py", line 194, in main
bootstrap(tmpdir=tmpdir)
File "./get-pip.py", line 82, in bootstrap
import pip
zipimport.ZipImportError: can't decompress data; zlib not available
When I tried to query for zlib, I see that it's already present:
[root#centos1 yum.repos.d]# rpm -qa | grep --color=auto -i 'zlib'
zlib-devel-1.2.3-7.el5
perl-Compress-Zlib-1.42-1.fc6
zlib-1.2.3-7.el5
perl-IO-Zlib-1.04-4.2.1
I tried installing zlib-devel, but still get the same error:
zipimport.ZipImportError: can't decompress data; zlib not available
How do I fix this and proceed in installing pip, as i've a need to proceed with the installation of awscli.

After installing "zlib" manually, after reinstall python again.
git clone https://github.com/madler/zlib.git
cd ${ZLIB_CLONED_DIR}
./configure --prefix=/usr/local
make
sudo make install
Rebuild the Python from source again
cd ${PYTHON_SRC_CODE_DIR}
./configure --prefix=${PYTHON_HOME_DIR}
make
sudo make install

the package python-pip is available in epel repo, install it by running yum install python-pip -y it will resolve any dependencies as well
after installing you can self update pip
pip install --upgrade pip then you can install awscli, pip install awscli

Related

Issue while installing Scipy

I installed Scipy using the command sudo apt-get install python-numpy python-scipy and looks like the latest version of both are installed. But when I try to install a python package named wfdb using pip install wfdb, it get an error while Building wheel for scipy (PEP 517).
ERROR: Failed building wheel for scipy
Running setup.py clean for scipy
ERROR: Command errored out with exit status 1:
command: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] =
'"'"'/tmp/pip-install-
fhfmfpqi/scipy/setup.py'"'"'; __file__='"'"'/tmp/pip-install-
fhfmfpqi/scipy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)
(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code,
__file__,
'"'"'exec'"'"'))' clean --all
cwd: /tmp/pip-install-fhfmfpqi/scipy
Complete output (9 lines):
`setup.py clean` is not supported, use one of the following instead:
- `git clean -xdf` (cleans all files)
- `git clean -Xdf` (cleans all versioned files, doesn't touch
files that aren't checked into the git repo)
Add `--force` to your command to use it anyway if you must (unsupported).
----------------------------------------
ERROR: Failed cleaning build dir for scipy
Failed to build scipy
ERROR: Could not build wheels for scipy which use PEP 517 and cannot be installed directly`
I upgraded pip using pip install --upgrade pip.
python version used: 3.7
Can I get some help on this?
Clean out the install (I don't know which system you're using) i.e. get rid of the $PATH variables and just do a fresh install.
If you're using Anaconda:
conda install -c anaconda scipy
should do it
also the goops old
pip install scipy
gets it done as well. May I ask why you approached your installation in this way (again, I don't know which system you're on)
Never do sudo pip. Instead do pip install --user. Or (better) work in a virtualenv.
EDIT: typo: there is no space between -- and user.

How can I fix an import error in kali Linux?

While Installing Man in the Middle Framework (MITMf) i get an ImportError:No Module named capstone..
Although Capstone is already installed in my Kali Machine
I downloaded MITMf from https://github.com/byt3bl33d3r/MITMf
Heres what i get
root#kali:~/Desktop/MITMf# python mitmf.py --help
Traceback (most recent call last):
File "mitmf.py", line 36, in <module>
from plugins import *
File "/root/Desktop/MITMf/plugins/filepwn.py", line 72, in <module>
from libs.bdfactory import pebin
File "/root/Desktop/MITMf/libs/bdfactory/pebin.py", line 49, in <module>
from intel.intelCore import intelCore
File "/root/Desktop/MITMf/libs/bdfactory/intel/intelCore.py", line 38, in <module>
from capstone import *
ImportError: No module named capstone
root#kali:~/Desktop/MITMf# pip install capstone
Requirement already satisfied: capstone in /usr/lib/python3/dist-packages (3.0.5)
root#kali:~/Desktop/MITMf#
You need to install the python2.7 version of capstone. It looks like your python installation is a little weird. On Debian systems such as Kali, pip should be the installer for python2 packages and pip3 should be the installer for python3 packages.
From the pip man page:
On Debian, pip is the command to use when installing packages for Python 2, while pip3 is the command to use when installing packages for Python 3.
You probably should fix your pip installation by linking pip2 to pip. The way we do this is removing the pip binary and creating a symlink from pip2:
[k#box]$ sudo rm /usr/bin/pip
[k#box]$ sudo ln -s /usr/bin/pip2 /usr/bin/pip
Then you should be able to install the python2.7 version with pip
[k#box]$ pip install capstone
Explanation:
You have installed the python3.6 version of capstone. You can see in the output of your pip install command:
root#kali:~/Desktop/MITMf# pip install capstone
Requirement already satisfied: capstone in /usr/lib/python3/dist-packages (3.0.5)
If you look at the script mitmf.py, you will notice that the top line specifies python2.7
[k#box]$ head -n3 mitmf.py
#!/usr/bin/env python2.7
# Copyright (c) 2014-2016 Moxie Marlinspike, Marcello Salvati

Exception: Failed to attach BPF to kprobe when executing sudo opensnoop-bpfcc

When I try to execute sudo opensnoop-bpfcc I get this message:
In file included from /virtual/main.c:4:
In file included from include/linux/sched.h:14:
In file included from include/linux/pid.h:5:
In file included from include/linux/rculist.h:11:
In file included from include/linux/rcupdate.h:40:
In file included from include/linux/preempt.h:81:
In file included from ./arch/x86/include/asm/preempt.h:7:
In file included from include/linux/thread_info.h:38:
In file included from ./arch/x86/include/asm/thread_info.h:53:
./arch/x86/include/asm/cpufeature.h:150:2: warning: "Compiler lacks ASM_GOTO support. Add -D __BPF_TRACING__ to your compiler arguments"
[-W#warnings]
#warning "Compiler lacks ASM_GOTO support. Add -D __BPF_TRACING__ to your compiler arguments"
^
1 warning generated.
Traceback (most recent call last):
File "/usr/sbin/opensnoop-bpfcc", line 127, in <module>
b.attach_kprobe(event="sys_open", fn_name="trace_entry")
File "/usr/lib/python2.7/dist-packages/bcc/__init__.py", line 526, in attach_kprobe
raise Exception("Failed to attach BPF to kprobe")
Exception: Failed to attach BPF to kprobe
I don't understand how to fix it. I've just installed bcc tools using this command
sudo apt-get install bpfcc-tools linux-headers-$(uname -r)
as suggested on the github page https://github.com/iovisor/bcc/blob/master/INSTALL.md#ubuntu---binary
The running OS is 18.04.2 LTS (Bionic Beaver).
I had to compile bcc from source code instead of installing it using the package.
Install linux kernel headers
sudo apt install linux-headers-$(uname -r)
Install required dependencies
sudo apt-get -y install bison build-essential cmake flex git libedit-dev \ libllvm6.0 llvm-6.0-dev libclang-6.0-dev python zlib1g-dev libelf-dev
Compile bcc from source code
git clone https://github.com/iovisor/bcc.git
mkdir bcc/build; cd bcc/build
cmake .. -DCMAKE_INSTALL_PREFIX=/usr
make
sudo make install
#Maicake is right. Compiling and installing from source did work for me. Here are the steps to install on Ubuntu 22.04:
Follow the steps described here. Specifically for Ubuntu 22.04 you may need to make some changes after cloning the bcc repository.
Add the following line to your .bashrc file:
export PATH=$PATH:/usr/share/bcc/tools
Create a symlink to python3 as most of the tools use python (not python3) to run the scripts.
sudo ln -s /usr/bin/python3 /usr/bin/python

pyenv install 3.6.3 error occurring : why?

user#syyun:~$ pyenv install 3.6.3
Downloading Python-3.6.3.tar.xz...
-> https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tar.xz
Installing Python-3.6.3...
BUILD FAILED (Ubuntu 16.04 using python-build 1.1.5-8-g7b9d1a4)
Inspect or clean up the working tree at /tmp/python-build.20171020004725.32507
Results logged to /tmp/python-build.20171020004725.32507.log
Last 10 log lines:
ensurepip._main()
File "/tmp/python-build.20171020004725.32507/Python-3.6.3/Lib/ensurepip/__init__.py", line 189, in _main
default_pip=args.default_pip,
File "/tmp/python-build.20171020004725.32507/Python-3.6.3/Lib/ensurepip/__init__.py", line 102, in bootstrap
_run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
File "/tmp/python-build.20171020004725.32507/Python-3.6.3/Lib/ensurepip/__init__.py", line 27, in _run_pip
import pip
zipimport.ZipImportError: can't decompress data; zlib not available
Makefile:1079: recipe for target 'install' failed
make: *** [install] Error 1
Can't locate any related google-search record for above given error on pyenv install command.
Any guidance would be appreciate
This question is answered in the pyenv wiki. You have to prep your build environment first before trying to build a Python interpreter using pyenv.
According to the wiki, you need the following packages installed for Ubuntu:
apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev xz-utils tk-dev

scipy missing libifport.so.5

I am trying to install scipy 0.10.1 on Ubuntu 10.10 using pip.
I have successfully installed numpy:
$ sudo pip install --upgrade numpy
[snip]
Successfully installed numpy
Cleaning up...
but when I try scipy I get:
$ sudo pip install --upgrade scipy
[snip]
File "/usr/local/lib/python2.6/dist-packages/numpy/linalg/linalg.py", line 23, in <module>
from numpy.linalg import lapack_lite
ImportError: libifport.so.5: cannot open shared object file: No such file or directory
I do have libifport.so.5, but I don't know why the installer isn't finding it.
$ echo $LD_LIBRARY_PATH
:/opt/intel/composerxe-2011.2.137/compiler/lib/intel64
I have also tried to install several other packages in the hope that one of them might help (e.g. libatlas-base-dev liblapack-dev libatlas-base-dev liblapack-dev, etc)
Any thoughts?
Thank you.
Most likely you have not defined the LD_LIBRARY_PATH for root. To check this:
$ sudo su
$echo $LD_LIBRARY_PATH
You can specify environment variables as follows:
$ sudo env LD_LIBRARY_PATH=path/to/compiler' pip install scipy
Check out this blog post to create an alias to save you typing each time:
http://final-world-domination.blogspot.ch/2011/02/sudo-doesnt-export-ldlibrarypath.html
This fixed the problem for me on Debian 9:
conda install -c intel -c conda-forge -c pytorch --override-channels intel-fortran-rt
# find / -iname "libifport*"
./opt/conda/lib/libifport.so
./opt/conda/lib/libifport.so.5
./opt/conda/pkgs/intel-fortran-rt-2021.3.0-intel_3350/lib/libifport.so
./opt/conda/pkgs/intel-fortran-rt-2021.3.0-intel_3350/lib/libifport.so.5