install sklearn for python3

I ran a python3 program and got error Traceback (most recent call last):File “main.py”, line 1, infrom sklearn.metrics.pairwise import pairwise_distancesModuleNotFoundError: No module named ‘sklearn’ It clearly says sklearn module is not available and second point to consider is I am using python3 and I have pyhton2 as well on my devbox. To sort it out,

Pip3 Install pip for python3

I have Ubuntu20 and by default if I check pip version I get it is for python2 But I want to use pip for pyhon3 and if I check pip3 I get following: Therefore I executed above command to have pip3 for python3 at my system : It displays a bit general information and asks

Regex to check top domain in DNS

Today I come to a situation where I need to find if my string has .com/.edu/.au/.info/.in or similar kind of word in it or not. And while designing a regex pattern I kept following thought process.. It will have alphanumeric characters, i.e letters, numbers, underscores and periods(dot), dashes, -, followed by a period(dot) and a

read N lines at a time file python

Here requirement is that, I want to process a file from row number N to row number N+X One solution might be, use itertools.islice to get the lines from the file between the given range of start and end.e.g for row no 3 to 6 : For example purpose I have take a file with

UserWarning: Could not import the lzma module

Got following error after import turicreate /home/prod/anj/learn/ml/mlvenv/lib/python3.7/site-packages/pandas/compat/__init__.py:117: UserWarning: Could not import the lzma module. Your installed Python is incomplete. Attempting to use lzma compression will result in a RuntimeError. warnings.warn(msg) Fix: I have ubuntu: For it sudo apt-get install liblzma-dev Reading package lists... Done Building dependency tree Reading state information... Done Now I will go to

Add python3.7 as alternate python along with default on Ubuntu

My default python is 2.7 and I want python 3.7 along with it: Go to opt directory $ cd /opt Create a directory $ mkdir python3 Download Python 3.7 $ wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz Extract the python 3.7 tar file $ tar xzf Python-3.7.4.tgz To compile the source go to $ cd Python-3.7.4 To get release build with all

Create a Virtual environment for python 3

I have Ubuntu and it has python 2.7 as default. Along with it I have configured python3 as well. To create a virtual environment for a python 3 project I have executed following virtualenv -p /usr/bin/python3 mlvenv It created a virtual environment named mlvenv Now to activate it source mlvenv/bin/activate To confirm python --version

c/_cffi_backend.c:2:20: fatal error: Python.h: No such file or directory

Error c/_cffi_backend.c:2:20: fatal error: Python.h: No such file or directory #include ^ compilation terminated. Traceback (most recent call last): File “”, line 17, in ———————————————————————- Here it is the problem of python devel For centos use “sudo yum install python-devel.x86_64” For Ubuntu use “sudo apt-get install python-dev”