I mostly use these tools below so this post will be updated frequently. My favorite runtime version manager(or tool version manager) is asdf nowadays 🙂
Continue readingRuntime Version Manager
How to install .NET with dotnet-install script
Find more details in Microsoft scripted installation
- .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.
- .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.
All .NET Core and .NET Versions Available for Installation via dotnet-install
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 readingPython Azure Function Debugging in Pipenv virtual environment
Creating virtual environment
$ mkdir python_demo
$ cd python_demo
$ pyenv local 3.9.6
$ pipenv --python $(pyenv which python)
$ pipenv --venv
$ pipenv install ptvsd -d
Continue reading conda vs pipenv vs virtualenv commands
find more information in conda
Task | Conda package and environment manager command | Pip package manager command | Virtualenv environment manager command |
---|---|---|---|
Install a package | conda install $PACKAGE_NAME | pip install $PACKAGE_NAME | X |
Update a package | conda update --name $ENVIRONMENT_NAME$PACKAGE_NAME | pip install --upgrade$PACKAGE_NAME | X |
Update package manager | conda update conda | Linux/macOS: pip install -Upip Win: python -m pipinstall -U pip | X |
Uninstall a package | conda remove --name $ENVIRONMENT_NAME$PACKAGE_NAME | pip uninstall $PACKAGE_NAME | X |
Create an environment | conda create --name $ENVIRONMENT_NAME python | X | cd $ENV_BASE_DIR; virtualenv$ENVIRONMENT_NAME |
Activate an environment | conda activate $ENVIRONMENT_NAME * | X | source$ENV_BASE_DIR/$ENVIRONMENT_NAME/bin/activate |
Deactivate an environment | conda deactivate | X | deactivate |
Search available packages | conda search $SEARCH_TERM | pip search $SEARCH_TERM | X |
Install package from specific source | conda install --channel $URL $PACKAGE_NAME | pip install --index-url $URL$PACKAGE_NAME | X |
List installed packages | conda list --name $ENVIRONMENT_NAME | pip list | X |
Create requirements file | conda list --export | pip freeze | X |
List all environments | conda info --envs | X | Install virtualenv wrapper, then lsvirtualenv |
Install other package manager | conda install pip | pip install conda | X |
Install Python | conda install python=x.x | X | X |
Update Python | conda update python * | X | X |
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:
- 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.
- 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