Showing posts with label Python. Show all posts
Showing posts with label Python. Show all posts

Thursday, October 7, 2021

Installing python3 and pip3 on Centos7

Here I have no python3 installed

The most simplest way to install python3
=================
sudo yum install python3

Make python 3.6 as default one
=================
sudo alternatives --install /usr/bin/python python /usr/bin/python3.6 60
sudo alternatives --config python

Check the python version
==================

Check the pip version
==================

Check the pip3 version
==================

Upgrade pip3
=================
pip3 install --upgrade pip --user



 

Check the pip version

==================


Bonus: Fixing yum package manager

Now lets try to install a random package to check the yum package manager

Install nano
=============
sudo yum install nano
you will get following error

To fix this, Open the /usr/bin/yum file and in the first line, change python to python2
OLD:


NEW:

If again you got similar issue with different file, for example:

Open this file (sudo vi /usr/libexec/urlgrabber-ext-down ) and in the first line change "python" to "python2"

 

Here is the Youtube demo:


 

 

-That's all for now

Monday, February 11, 2019

Installation of Cloudify CLI on Ubuntu 14.04 for service deployment using TOSCA standard

In this post we will see how to install Cloudify CLI, through which we can deploy, scale and monitor the different cloud service. For better understanding lets install this in local machine. The basic steps can be refereed and extended for actual cloud environment.

The steps are as follows:
Environment: we will be using Ubuntu 14.04, Python 2.6/2.7
Cloudify  does NOT support Python 3

Step 1: Install Docker on local machine. [ How to install Docker on Ubuntu 14.04? ]
Step 2: Open ubuntu terminal
Step 3: Run the following command

sudo docker run --name cfy_manager_local \
    -d --restart unless-stopped \
    -v /sys/fs/cgroup:/sys/fs/cgroup:ro \
    --tmpfs /run \
    --tmpfs /run/lock \
    --security-opt seccomp:unconfined \
    --cap-add SYS_ADMIN \
    -p 80:80 \
    -p 8000:8000 \
    cloudifyplatform/community:18.10.4


Step 4: Now go to web browser and enter localhost or enter your own IP
             You can see the web interface of the Cloudify Console
Step 5: Enter admin as both username and password.


NEXT: Service Deployement on local machine using Cloudify CLI



Friday, May 25, 2018

Classification using NaiveBayse Algorithm using Python

#Import Library of Gaussian Naive Bayes model
from sklearn.naive_bayes import GaussianNB
import numpy as np
import pandas as pd
 
#assigning predictor and target variables
dataF = pd.DataFrame()
dataF["x1"] = np.random.random_sample((5,)) + 1
dataF["x2"] = np.random.random_sample((5,)) + 2 

dataL = pd.DataFrame()
dataL = np.array([3, 3, 4, 3, 4])
 
#Create a Gaussian Classifier
model = GaussianNB()

# Train the model using the training sets 
model.fit(dataF, dataL)

#Predict Output 
predicted= model.predict([[1,2],[3,4]])
print(predicted)

Output: ([3,4])
 
-Thank you 

Wednesday, May 23, 2018

Basic Panda's functions for dataset manipulation in Python


Let we have two tables
Data1.schema:
    name:
    Company:
    Address:
Data2.schema:
    Name:
    gender:
    Age:

Commands:


# delete a column

del Data1[“name”]

# Return all the rows of the ‘name’ column

data1.loc[:, ‘name’]

# Return all the rows from ‘name’ column to ‘Company’ column

data1.loc[:, ‘name’:’Company’]

# Return all the rows from ‘Company’ column to ‘Address’ column

data1.loc[:, ‘Company’:’Address’]

# Return the rows whose Address is “India”

data1.loc[lambda var: var.Address == “India”, : ]
or
data1.loc[data1[“Address”] == “India”, :]

# Return only the name whose Address is “India”

data1.loc[lambda var: var.Address == “India”, ’name’]

# Return only the first five names whose Address is “India”

data1.loc[lambda var: var.Address == “India”, ’name’].head(5)

# Return only the last five names whose Address is “India”

data1.loc[lambda var: var.Address == “India”, ’name’].tail(5)

# Return the list of unique Addresses

data1.Address.unique()

# Return the list of unique Companies

data1.Company.unique()

# Return the list of unique names

data1.name.unique()

# Return the first unique Address

data1.Address.unique()[0]

# Return the total number of unique Addresses

data1.Address.unique().size

# Return the name, age and gender from data2 if the Address is India

t = data1.loc[data1[“Address”] == “India”, “name”].unique()
for x in range(0,t.size)
    data[2].loc[data2[“name”]==t[x],:]

Thursday, November 24, 2016

Installing packages (Python, R and Scala) with Anaconda.

Anaconda makes the package management of Python, R and Scala very easy. For this you need to have Anaconda-navigator package installed in your computer.



1. Open Command prompt
2. Enter conda install anaconda-navigator
3. Press Enter key to proceed.

Now open anaconda navigator application. Below is the Home screen of Anaconda navigator.
1. Home Screen


Click on Environments, as shown below
2. Environment screen


Change the Installed option to All option Select
3. Change "Installed" to "All" option

4. Differentiate "Installed", "Not installed" and "Upgradable " packages.

Now Type the required package in the Search box.
Lets install "pandasql" package . So type pandasql in the search box. Now you can see the search result.

5. Search required package


Now right click on the checkbox in the respective search result. From the options , select "Mark for installation"

6. Installation option


Click on "Apply" button.
Now click on "Ok" button.
7. Final steps.


Its finish. Repeat the same process for installing other packages.




Installing Anaconda in Windows OS.


Step 1: Download
First step is to download the latest version of Anaconda for Windows OS.

For Windows 64bit (Python 3.5): https://repo.continuum.io/archive/Anaconda3-4.2.0-Windows-x86_64.exe
For Windows 32bit (Python 3.5):  https://repo.continuum.io/archive/Anaconda3-4.2.0-Windows-x86.exe

For Windows 64bit (Python 2.7): https://repo.continuum.io/archive/Anaconda2-4.2.0-Windows-x86_64.exe
For Windows 32bit (Python 2.7):  https://repo.continuum.io/archive/Anaconda2-4.2.0-Windows-x86.exe

You can also download from official link https://www.continuum.io/downloads.

Step 2 : Install
Install Anaconda 3.5 (Python 3.5)
  1. Double click on the downloaded file.
  2. Follow the wizard.
  3. Select "Just me..." option, and click on "Next" button.
  4. In the "Advanced Installation Options", please make sure that "Add Anaconda to my PATH...." and "Register Anaconda....."  options are checked.
  5. now just follow the wizard and finish the installation process.

Step 3: Verify the installation
Open command prompt
Enter following command
 conda --version

Thursday, October 6, 2016

Installing OpenCV and Python in Windows


1. Download and install Python 2.7.x in windows
             windows install : http://python.org/ftp/python/2.7.5/python-2.7.5.msi
2.  The default installation directory C:\Python27


3. Download and install python package manager pip if NOT installed
                  A. Download get-pip.py script from  https://bootstrap.pypa.io/get-pip.py
                  B. Open command prompt
                  C. Enter following command to run the downloaded script
                                    python <path to get-pip.py file>

4.  Go to http://www.lfd.uci.edu/~gohlke/pythonlibs/ to download and install python packages

5.  Now, Download Numpy python package (choose the .whl file based on your requirement)
                  A. Open command prompt
                  B. Go to the local directory where numpy-1.11.2+mkl*.whl file is present
                  C. Enter following command to Install Numpy
                                    pip install numpy-1.11.2*.whl
6. You can repeat Step-5 to install other required packages


7. Download and install OpenCV
                  A. Folllow the link to download OpenCV-3.1.0
                  B. Open the .exe file to install (in C drive)
                  C. Goto C:\opencv\build\python
                  D. Copy cv2.d to C:\Python27\Lib\site-packages

Please comment if you encounter any error....

-Thank you