How to install .NET with dotnet-install script

Find more details in Microsoft scripted installation

  1. .NET SDK (Software Development Kit): The SDK includes everything you need to build and run .NET applications. This means it includes the runtime, but also includes other tools for developing, building, running, and testing .NET applications. This includes the .NET CLI (Command Line Interface), compilers, and libraries. You need the SDK to develop and build .NET applications.
  2. .NET Runtime: The runtime includes just the resources required to run existing .NET applications. It does not include the tools and libraries used for building applications. It's a smaller installation package compared to the SDK. When you deploy a .NET application to a server or a client machine, you usually only need to have the appropriate .NET Runtime installed on that machine, not the full SDK.

Installation

$ curl -sSL https://dot.net/v1/dotnet-install.sh > dotnet-install.sh
$ chmod +x dotnet-install.sh
$ echo 'export DOTNET_ROOT=$HOME/.dotnet' >> ~/.zshrc
$ echo 'export PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools' >> ~/.zshrc

dotnet-install Script Reference

find reference for dotnet-install script reference in dotnet-install script reference

find options for dotnet-install script in dotnet-install script options

Continue reading

conda vs pipenv vs virtualenv commands

find more information in conda

TaskConda package and environment manager commandPip package manager commandVirtualenv environment manager command
Install a packageconda install $PACKAGE_NAMEpip install $PACKAGE_NAMEX
Update a packageconda update --name $ENVIRONMENT_NAME$PACKAGE_NAMEpip install --upgrade$PACKAGE_NAMEX
Update package managerconda update condaLinux/macOS: pip install -Upip Win: python -m pipinstall -U pipX
Uninstall a packageconda remove --name $ENVIRONMENT_NAME$PACKAGE_NAMEpip uninstall $PACKAGE_NAMEX
Create an environmentconda create --name $ENVIRONMENT_NAME pythonXcd $ENV_BASE_DIR; virtualenv$ENVIRONMENT_NAME
Activate an environmentconda activate $ENVIRONMENT_NAME*Xsource$ENV_BASE_DIR/$ENVIRONMENT_NAME/bin/activate
Deactivate an environmentconda deactivateXdeactivate
Search available packagesconda search $SEARCH_TERMpip search $SEARCH_TERMX
Install package from specific sourceconda install --channel $URL $PACKAGE_NAMEpip install --index-url $URL$PACKAGE_NAMEX
List installed packagesconda list --name $ENVIRONMENT_NAMEpip listX
Create requirements fileconda list --exportpip freezeX
List all environmentsconda info --envsXInstall virtualenv wrapper, then lsvirtualenv
Install other package managerconda install pippip install condaX
Install Pythonconda install python=x.xXX
Update Pythonconda update python*XX

How to create virtual environment with conda

Conda is an open-source package management system and virtual environment management system that runs on Windows, macOS, and Linux. It was created for Python programs but it can package and distribute software for any language such as R, Ruby, Lua, Scala, Java, JavaScript, C, C++, FORTRAN.

The two main purposes of Conda are:

  1. Package management: Conda makes it easy to manage and install packages, even for different versions of Python. In addition, it also supports binary package management, which makes it an efficient way to handle packages and dependencies in your projects.
  2. Virtual Environment management: Conda allows you to create separate environments containing files, packages, and their dependencies that will not interact with other environments. When switching between Python versions for different projects, Conda makes it simple to use the specific version you need.

While pip can install Python packages, Conda can install packages for any language. Conda packages are binaries, which eliminates the need to compile the code which makes installations faster and more straightforward.

Installing conda

$ brew update
$ brew install --cask miniconda

Checking conda version

$ conda --version

conda 23.3.1

Conda help

$ conda -h
usage: conda [-h] [-V] command ...

conda is a tool for managing and deploying applications, environments and packages.

Options:

positional arguments:
  command
    clean             Remove unused packages and caches.
    compare           Compare packages between conda environments.
    config            Modify configuration values in .condarc. This is modeled after the git config command. Writes to the
                      user .condarc file (/Users/kenanhancer/.condarc) by default. Use the --show-sources flag to display
                      all identified configuration locations on your computer.
    create            Create a new conda environment from a list of specified packages.
    info              Display information about current conda install.
    init              Initialize conda for shell interaction.
    install           Installs a list of packages into a specified conda environment.
    list              List installed packages in a conda environment.
    package           Low-level conda package utility. (EXPERIMENTAL)
    remove (uninstall)
                      Remove a list of packages from a specified conda environment. Use `--all` flag to remove all packages
                      and the environment itself.
    rename            Renames an existing environment.
    run               Run an executable in a conda environment.
    search            Search for packages and display associated information.The input is a MatchSpec, a query language for
                      conda packages. See examples below.
    update (upgrade)  Updates conda packages to the latest compatible version.
    notices           Retrieves latest channel notifications.

options:
  -h, --help          Show this help message and exit.
  -V, --version       Show the conda version number and exit.

conda commands available from other packages (legacy):
  content-trust
  env
Continue reading

How to create virtual environment with pyenv-virtualenv plugin

pyenv-virtualenv is a pyenv plugin that provides features to manage virtualenvs and conda environments for Python on UNIX-like systems.

If you don't have pyenv in your system, follow below post;

Installing pyenv-virtualenv

$ brew update
$ brew install pyenv-virtualenv

Setting PATH

Run one of the following commands in terms of your shell's .rc file.

$ echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc
$ echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.zshrc

Creating virtual environment

$ mkdir python_demo
$ cd python_demo
$ pyenv install 3.11.4
$ pyenv virtualenv 3.11.4 python_demo-3.11.4
$ pyenv virtualenvs
$ pyenv prefix python_demo-3.11.4
/Users/kenanhancer/.pyenv/versions/python_demo-3.11.4
$ ls -Llat $(pyenv prefix python_demo-3.11.4)

drwxr-xr-x  14 kenanhancer  staff  448 19 Jun 17:36 bin
-rw-r--r--   1 kenanhancer  staff  107 19 Jun 17:36 pyvenv.cfg
drwxr-xr-x   3 kenanhancer  staff   96 19 Jun 17:36 lib
drwxr-xr-x   2 kenanhancer  staff   64 19 Jun 17:36 include
$ tree -a -L 4 $(pyenv prefix python_demo-3.11.4)

├── bin
│   ├── Activate.ps1
│   ├── activate
│   ├── activate.csh
│   ├── activate.fish
│   ├── pip
│   ├── pip3
│   ├── pip3.11
│   ├── pydoc
│   ├── python -> python3.11
│   ├── python3 -> python3.11
│   └── python3.11 -> /Users/kenanhancer/.pyenv/versions/3.11.4/bin/python3.11
├── include
│   └── python3.11
├── lib
│   └── python3.11
│       └── site-packages
│           ├── _distutils_hack
│           ├── distutils-precedence.pth
│           ├── pip
│           ├── pip-23.1.2.dist-info
│           ├── pkg_resources
│           ├── setuptools
│           └── setuptools-65.5.0.dist-info
└── pyvenv.cfg
Continue reading

How to install Python with pyenv version manager

I am using different programming languages like C#, Java, Node.js etc and need to manage runtime versions in my local. So, I like to use runtime version managers.

For example, there are some runtime version managers in Node.js community like nvm or n.

Let's say I work for one Node.js project in dev machine with Node v8.0.0 but other project needs Node v6.0.0

In order to handle, different versions in same machine, we may use runtime version managers.

I just want to find a way to switch between different Python runtime version so that found pyenv runtime version manager.

Pyenv is a simple, powerful and cross-platform tool for managing multiple versions of Python on a single machine. It is very useful when you need to switch between different Python versions for different projects, or when different applications on your system require different Python versions.

So, we can install, uninstall, list or switch between different versions.

Pyenv installation

Click pyenv link for more detailed installation.

Installing pyenv with Homebrew

First, ensure that you have Homebrew installed in your system. Homebrew is a package manager for Mac OS. So if you want to learn more details about it, visit my post.

Run the following commands in your terminal. But, just copy commands without $ sign.

$ brew update
$ brew install pyenv

Setting PATH

Checking shell

output of echo $SHELL can be bash, zsh or fish

$ echo $SHELL

/usr/local/bin/bash

# OR

/bin/zsh

Run the following command for bash, zsh, etc configuration.

$ echo 'eval "$(pyenv init -)"' >> ~/.zshrc

and restart your terminal manually or run the following command to restart automatically.

$ exec "$SHELL"

Upgrading pyenv

$ brew upgrade pyenv

Uninstall pyenv

$ rm -rf $(pyenv root)
$ brew uninstall pyenv

Pyenv commands

List all Python versions installed in system

$ pyenv versions

  system
  3.7.3
* 3.8.2 (set by /Users/kenanhancer/.pyenv/version)

Show current active Python version in system

$ pyenv version

3.8.2 (set by /Users/kenanhancer/.pyenv/version)
Continue reading