technical skills grow

Responsive Ads Here

Thursday, September 10, 2020

Virtual Environment & Requirements | Python

 

I have python source code in 3.5 but I want to use this code in 3.6 so we need create Virtual environment  .

Need ?

I have create website 5 year ago so i will share with my friend so he will install python  and create environment  but after five year package also change with time .So it is need same package so i will share those time package with

Requirements.txt

How ?

 #saurabh@server:~/python$ pip install virtualenv


Step 2:

saurabh@server:~/python$ virtualenv envdir

 

Step 3: After install create new folder it is create clone in env


 saurabh@server:~/python$ sudo  apt-get install python3-venv

 saurabh@server:~/python$ python3 -m venv env


  finally create virtually environment 


Now Active environment

Step 5:

(env) saurabh@server:~/python$ source env/bin/activate

Now You can install sk learn module in virtual environment .

Step 6: Now install package 

(env) saurabh@server:~/python$ pip install sklearn

Collecting sklearn
  Downloading https://files.pythonhosted.org/packages/1e/7a/dbb3be0ce9bd5c8b7e3d87328e79063f8b263b2b1bfa4774cb1147bfcd3f/sklearn-0.0.tar.gz
Collecting scikit-learn (from sklearn)
 

Step 7: Create  requirements.txt file it is store package

(env) saurabh@server:~/python$ pip freeze > requirements.txt
You are using pip version 8.1.1, however version 20.2.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
(env) saurabh@server:~/python$ ls
1.py  2.py  dic.py  dis.py  elif.py  env  envdir  loop.py  requirements.txt
(env) saurabh@server:~/python$ 

Using requirements files

installing packages using, pip allows you to declare all dependencies in a Requirements File.

 For example you could create a  

requirements.txt

requests==2.18.4
google-auth==1.1.0

Now i want to install requirements file package 

pip install -r requirements.txt



No comments:

Post a Comment

Powered by Blogger.

Labels

Contact Form

Name

Email *

Message *

Search This Blog

Blog Archive

Ad Code

Responsive Advertisement

Recent Posts