I. Python+pip on Linux:
1. Need OpenSSL to avoid error: (and configure ./configure --with-ssl)
wget https://www.openssl.org/source/openssl-1.1.1g.tar.gzmake -j 8
tar -xf openssl-1.1.1g.tar.gz
cd openssl-1.1.1g
./config --prefix=/home1/p001cao/local/app/tool_dev/openssl \
--openssldir=/home1/p001cao/local/app/tool_dev/openssl
make install
tar -xf libffi-3.3.tar.gz
cd libffi-3.3
cd libffi-3.3
./configure --prefix=/home1/p001cao/local/app/tool_dev/libffi-3.3
Download
export PYTHON_VERSION=3.7.5
curl -O https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz tar -xvzf Python-${PYTHON_VERSION}.tgz cd Python-${PYTHON_VERSION}
Build and install Python#
Configure, make, and install Python:
./configure \
--prefix=/uhome/p001cao/local/app/python/${PYTHON_VERSION} \
--enable-shared \
--enable-ipv6 \
LDFLAGS=-Wl,-rpath=/uhome/p001cao/local/app/python/${PYTHON_VERSION}/lib,--disable-new-dtags
make -j 8 make install
REF; https://docs.rstudio.com/resources/install-python-source/
Configure, make, and install Python:
./configure \ --prefix=/uhome/p001cao/local/app/python/${PYTHON_VERSION} \ --enable-shared \ --enable-ipv6 \ LDFLAGS=-Wl,-rpath=/uhome/p001cao/local/app/python/${PYTHON_VERSION}/lib,--disable-new-dtags
create module python3
module load openSSL
prepend-path PATH $topdir/bin
prepend-path INCLUDE $topdir/include
prepend-path LD_LIBRARY_PATH $topdir/lib
Test:
module load tool_dev/python37
python3 -V
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade pip --trusted-host pypi.org --trusted-host files.pythonhosted.org
2. Setting Up a Virtual Environment
Setting up a programming environment provides us with greater control over our Python projects and over how different versions of packages are handled.
venv (for Python 3) and virtualenv (for Python 2) allow you to manage separate package installations for different projects. They essentially allow you to create a “virtual” isolated Python installation and install packages into that virtual installation. When you switch projects, you can simply create a new virtual environment and not have to worry about breaking the packages installed in the other environments.
Choose which directory you would like to put your Python programming environments in, or create a new directory in installing dir of python:
cd /uhome/p001cao/local/python/Python37
mkdir enviroments
cd enviroments
module load python/python37
python3 -m venv py37impi
source py37impi/bin/activate
module load openSSL
prepend-path PATH $topdir/bin
prepend-path LD_LIBRARY_PATH $topdir/lib
prepend-path INCLUDE $topdir/include
if { [ module-info mode load ] } {
puts stdout "source $topdir/bin/activate;"
} elseif { [ module-info mode remove ] } {
puts stdout "deactivate"
}
create module python/python37
set topdir /uhome/p001cao/local/python/Python37/enviroments/py37impimodule load openSSL
prepend-path PATH $topdir/bin
prepend-path LD_LIBRARY_PATH $topdir/lib
prepend-path INCLUDE $topdir/include
if { [ module-info mode load ] } {
puts stdout "source $topdir/bin/activate;"
} elseif { [ module-info mode remove ] } {
puts stdout "deactivate"
}
2. Install packages:
load corresponding envs:
module load python/py37impi
python3 -m pip install --upgrade pip
module load python/py37impi
python3 -m pip install --upgrade pip
pip3 install tess ovito numpy scipy matplotlib mpi4py impi
III. Some problems:
SSL:
https://joshspicer.com/python37-ssl-issue
III. Some problems:
SSL:
https://joshspicer.com/python37-ssl-issue
wget https://www.openssl.org/source/openssl-1.0.2q.tar.gz
tar xvf openssl-1.0.2q.tar.gz
cd openssl-1.0.2q
./config --prefix=/uhome/p001cao/local/openssl-1.0.2
make
make install
create module openSSL
set topdir /uhome/p001cao/local/openssl-1.0.2
prepend-path PATH $topdir/bin
prepend-path LD_LIBRARY_PATH $topdir/lib
prepend-path INCLUDE $topdir/include
IV. Install package from source
cd sourceFolder
pip install -e .
No comments:
Post a Comment