Skip to main content

Python - Working With Conda

 Python - Working with Conda

Getting Conda Environment Info

$conda info

Login to Conda Environment

$export PATH=”/app/miniconda3/bin:$PATH”

$source activate [env_name]

How to get Module installed path

>>>import module

>>>print(module.__file__)

 

Export Modules to file

$conda list --explicit > env_name.txt

Listing Environments

$coda env list

Creating New Environment

$conda config --add channels conda-forge  #after this we can get file ~/.condarc

$vi condarc #set proxy in condarc file

~/.condarc

channels:

-          conda-forge

-          defaults

proxy-servers:

      http:http://company.com

      https:http://company.com

 

$conda create --name [env_name] --file env_name.txt

Installing miniconda by logging as root

#cat /etc/wgetrc   #add proxies to wget for http,https,fttp

http_proxy=

https_proxy=

fttp_proxy=

#wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O /app/miniconda3/miniconda.sh

root@server:/app/minconda3 #sha256sum miniconda.sh

root@server:/app/minconda3 #bash miniconda.sh

 

Installing google cloud sdk (https://cloud.google.com/sdk/docs/install)

root@server:/app #tee -a /etc/yum.repos.d/google-cloud-sdk.repo <<EOM

>[google-cloud-sdk]

>name=Google Cloud SDK

>baseurl=https://packages.cloud.google.com/yum/repos/cloud-sdk-el7-x86_64

>enabled=1

>gpgcheck=1

>repo_gpgcheck=1

>gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg

>    https: ://packages.cloud.google.com/yum/doc/rpm-package-key.gpg

> EOM

root@server:/app#yum install google-cloud-sdk

 

$conda create -n gcp_38 python

$source activate gcp_38

 

To get packages from Python

>>>import pip

>>>for pkg in pip.get_installed_distribution(local_only=True):

          print(pkg)

 

Or

$pip freeze or $conda list

In Pandas to get all columns displayed use below

>>>import pandas as pd

>>>pd.set_option(‘display_max_rows’,None)

 

 


Comments