Running debian jessie
I installed Ansible using the following procedure:
apt-get update
sudo apt-get install python-yaml python-pip python-jinja2 python-paramiko pip
git clone https://github.com/ansible/ansible.git
cd ansible
git submodule update --init --recursive
sudo make install
Is there a way to cleanly uninstall Ansible that does not involve sifting through my directory tree and deleting?
The aim is to reinstall Ansible version 1.9 instead of the latest 2.1.0
Your best bet is to install checkinstall, run the install again under checkinstalls control, and then use dpkg to remove things.
https://wiki.debian.org/CheckInstall
There is a directory list in the source code repo telling you which directories ( and files ) are created. This is used to build the .deb package, but you can easily use it the other way around:
packaging/debian/ansible.dirs
if you have installed on redhat centos based systems
you can do below to uninstall ansible cleanly and similar command for ubuntu debian based systems
rpm -qa | grep ansible | xargs rpm -e
rpm -qa | grep -i epel | xargs rpm -e
else yum remove ansible
As I see you cloned ansible from git. Try to remove ansible folder, but first, go to cloned folder and write
make uninstall
then
cd ..
rm -r ansible_folder
and dependent folders, files for example '/etc/ansible' folder.
I had built ansible 2.1.1 from source then wanted to downgrade to 2.1.0 using yum. The trick i learned was to go to /lib/python2.7/site-packages and deleting the ansible-2.1.1.0-py2.7.egg-info directory. In my case, using yum properly added files to /etc/ansible and /usr/bin, but as long as the old (newer version number) egg was there, then ansible --version continued to show the newer version number.
After removing ansible using dnf remove ansible uninstall python and reinstall ansible it will show the newer version.
Related
I am new on linux and i tried to change the Symbolic link of python3 in /usr/bin/ ,
and i accidentally remove the python3.9 file !
But i know i didn't delete it completely Because there is still a lot of file called python3.9 .
After that 'apt' didn't work anymore and i got this error :
E: Problem executing scripts APT::Update::Post-Invoke-Success 'if /usr/bin/test -w /var/lib/command-not-found/ -a -e /usr/lib/cnf-update-db; then /usr/lib/cnf-update-db > /dev/null; fi'
Now , I only have version 2.7 of python and i can't install another because apt don't work !!
This is the result of
:
So I hope someone can help me and I wish you a good afternoon
Edit: As you've lost apt command meaning you can't install or remove anything using apt command.
The possible way to fix this is by reinstalling respective apt-package of your architecture and then do the below python installation.
To install apt-package again download the .deb file from the “/etc/apt/sources.list” file. Lots of links for installation and upgrades for packages will be in this file.
Now find the downloading source using $cat /etc/apt/sources.list command.
Find /pool/main/a/apt/ directory under downloading source and then download the .deb file which matches your architecture and download it.
Thereafter install this using dpkg command like this
sudo dpkg -i PackageName.deb
Replace the PackageName with your file name (e.g- apt_1.6.13_arm64/apt_1.9.3_i386).
Restart the PC and then check the /usr/bin/ directory to ensure if it had properly installed .
If you get nothing there then run locate apt-get command to locate it. If you can't get it then there is no other way than reinstalling the OS itself.
If you have reinstalled apt then
use the following commands to freshly install Python.
Note that all the commands below will be for Python3 as you're concerned with version 3.9.
# To uninstall the Python only
sudo apt-get remove python3.9
# To uninstall the Python with all the packages also
sudo apt-get remove --auto-remove python3.9
# To remove all the dependencies and configuration files
sudo apt-get purge --auto-remove python3.9
Now to install the Python3. The following command will install the latest version of python3. which to this date is python3.9.
sudo apt-get install python3
You can use pip to manage the python packages also.
To install pip use the following command
sudo apt install python3-pip
Now to manage the python packages using pip
# To install package; replace PackageName with the name of package(like flask)
sudo pip install PackageName
# To uninstall package
sudo pip uninstall PackageName
If you get trouble with pip get list of all the commands pip uses with
sudo pip help
You can list all the Python version installed (on default location)
ls /usr/bin/python*
Hope this will help in resolving the problem.
I have a CentOS 6.4 which the default python version is 2.6.
I want to run a virtualenv at python 2.7, so first I try to install python 2.7.
yum install python27
Then I run
virtualenv -p /usr/bin/python2.7 ./venv
Then the output shows that it try to get setuptools from pypi, but my environment can not reach pypi.python.org. I have update the ~/.pip/pip.conf to use a available local source but the virtualenv still get pip from the pypi.python.org. This is one of the things I get confused.
I check the /usr/lib/python2.7/, the site-packages is empty while /usr/lib/python2.6/ is not. So When I use python 2.7, it has nothing available. When I use the default python, it has pip tools installed, it does not need to get it from pypi.python.org.
How can I install pip for python 2.7 individually?
Previous I install pip by
yum install python-setuptools
yum install python-pip
The second question, how to install pip for python2.7 individually can be solved as the following:
Download python source code of the specific version and install it at /usr/local
wget http://python.org/ftp/python/2.7.6/Python-2.7.6.tar.xz
tar xf Python-2.7.6.tar.xz
cd Python-2.7.6
./configure --prefix=/usr/local --enable-unicode=ucs4 --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib"
make && make altinstall
Then install setuptools and pip
Install easy_install (prepare ez_setup.py beforehand)
python2.7 ez_setup.py
Install pip
easy_install-2.7 pip
easy_intall-2.7 pip need to visit the internet, in my environment I get the pip source file and use "python2.7 setup.py install".
pip2.7 install [packagename]
In my environment I update .pip/pip.conf to use an internal pip source.
(code above take python 2.7 as an example)
To see the details you can check the following url:
http://toomuchdata.com/2014/02/16/how-to-install-python-on-centos/
The first question, when creating a new virtual environment, virtualenv will install setuptools for this environment. If python version is not assigned, it use the system default python and default pip. If pip is not find, then try to get it from pypi.python.org.
In my environment, after python2.7 and pip2.7 installed, when trying to create a new virtualenv, it still get pip from pypi.python.org, I guess that virtualenv does not find the relation between python2.7 and pip2.7.
If you can visit pypi.python.org, that is fine.
If you are at an internal environment that can not visit pypi.python.org, virtualenv provides -extra-search-dir and --never-download command. So you can prepare the setuptools beforehand, copy it from U-disk,using scp, or other solutions.
Move setuptools-0.6c11-py2.7.egg to /usr/local/bin.
Finally we can use virtualenv by
virtualenv -p /usr/local/bin/python2.7 --extra-search-dir /usr/local/bin/ --never-download venv
My laptop has been formatted and new OS was installed, and since then I get this error:
ImportError: No module named git
This refers to a python code which simply imports git.
Location of git before my laptop was formatted: /usr/local/bin/git
Location of git after the laptop was formatted: /usr/bin/git
How / what do I change in my python code to refer to right path ?
The git module is not the same thing as the git command line executable. They happen to have the same name and cover related tasks, but they are distinct software packages.
I'm going to assume that the git module your code is importing is the one provided by the GitPython project. You'll need to install that project, see their installation instructions:
# pip install gitpython
In my cas, I installed pythong2-git, it solved my problem.
sudo apt-get install python3-git
In my case apt install python-git fixed the issue.
You can try this.
GitPython’s git repo is available on GitHub, which can be browsed at:
https://github.com/gitpython-developers/GitPython
and cloned using:
$ git clone https://github.com/gitpython-developers/GitPython git-python
Initialize all submodules to obtain the required dependencies with:
$ cd git-python
$ git submodule update --init --recursive
In Centos7 (might also work in Redhat System), if you are using Python2.7 :
sudo yum install epel-release
sudo yum install python-pip
sudo yum install GitPython.noarch
The above command is to install gitpython in Python2
I'm no Python or CentOS (CloudLinux 6.6 + WHM/cPanel) expert, but I'm trying to install an updated version of Python under CentOS with some extra packages and keeping the system version working.
I managet to get Python 2.7 installed by:
yum groupinstall -y development
yum install -y zlib-dev openssl-devel sqlite-devel bzip2-devel
wget https://www.python.org/ftp/python/2.7.6/Python-2.7.6.tgz
tar xzf Python-2.7.6.tgz
cd Python-2.7.6
./configure --prefix=/usr/local
make
sudo make alt install
If I run python I get Python 2.6.6 and python2.7 gives me Python 2.7.6. Yum also seems to work fine, so I guess I didn't break the system.
Now, my problem is, I need to get Twistd installed on the Python 2.7, and it needs zope.interface also.
How can I install both of them on the Python 2.7 installation at /usr/local?
Also, after that if I want to run a setup for a twistd plugin and run it under the python 2.7 how should I do it?
Thank you.
I would use virtualenv for this. Here is the steps that you can follow:
install virtualenv:
sudo yum install virtualenv
wget bootstrap.pypa.io/get-pip.py
python get-pip.py --user
pip install virtualenv
create a virtual env for you app, and precise the python binary you want to use:
virtualenv -p /usr/local/bin/python2.7 ~/venv
Activate it:
source ~/venv/bin/activate
now you are in you virtual env. every python command that you will run will use the python2.7 specified in the command line. Also you can now use pip to install python packages (again, only in your virtual env folder):
pip install Twisted
Dependencies will be handled automatically.
Note that you may need some dev rpm packages as Twisted needs some C compilation.
How can I update all python modules I have installed on ubuntu?
Ubuntu's repositories usually contain up-to-date versions of Python modules (prefixed with python-) and if you do an apt-get dist-upgrade will update any that you've installed from the repos.
As for packages you may have installed with easy_install, you could use distribute to upgrade them.
Alternatively, you can construct a list of packages you have installed with yolk, and pass the packages in the list from yolk -l to easy_install.
Here is a one click simple command to do so:
pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs sudo pip install -U
Checkout setuptools (a/k/a "easy_install"), the classic way of doing it, or distribute, the new way to handle all your Python module installation needs.