pyenv+virtualenv on High Sierra


  • Install pyenv on Macos High Sierra
brew update
brew install pyenv
brew install pyenv-virtualenv
  • Install required python version:
export CFLAGS="-I$(brew --prefix openssl)/include"
export LDFLAGS="-L$(brew --prefix openssl)/lib"
pyenv install

  • add to bashprofile
###PYENV 
export PYENV_ROOT=/usr/local/opt/pyenv
eval "$(pyenv init -)"
if which pyenv-virtualenv-init > /dev/null; then eval "$(pyenv virtualenv-init -)"; fi
alias pyt='pyenv activate'
alias pys='pyenv shell'
alias pyd='pyenv deactivate'
alias pyu='pyenv uninstall' #delete virtualenv
alias pyv='pyenv virtualenv' #create virtualenv
alias pyls='pyenv virtualenvs' #list virtualenvs
export PYENV_VIRTUALENV_DISABLE_PROMPT=1 #disable deprecated future






Automatic install and setup VNC server on Ubuntu

I use a script to automaticly install and setup VNC on many computers in my network.

Its easy.

sudo nano vncinstall

Paste this into it:

#!/bin/sh
apt-get -y remove --purge vino
apt-get -y install x11vnc
mkdir /etc/x11vnc
chmod 755 /etc/x11vnc
x11vnc -storepasswd yourvncpassword /etc/x11vnc/passwd
chmod 644 /etc/x11vnc/passwd
cat > /etc/init/x11vnc.conf <<_EOF
start on login-session-start
script
x11vnc -xkb -bg \
 -noxrecord \
 -noxfixes \
 -noxdamage \
 -display :0 \
 -auth /var/run/lightdm/root/:0 \
 -rfbauth /etc/x11vnc/passwd \
 -forever \
 -o /var/log/x11vnc.log
end script
_EOF

Then just:
sudo chmod +x vncinstall
sudo sh vncinstall

Your VNC server will be available on port 5900 and You will be able to interact with user.

How to install another python version on ubuntu 12.04

This post was written in 2012.
Since then many time has passed, and my recommendation is to use pyenv + virtualenv

Original text is below:

So, ubuntu 12.04 comes with python 2.7 or 3.2 by default.

If installing 3.2 is easy as
sudo apt-get install python3

When you whant to install unsupported python version, you starting to have some troubles.
You can use projects like pyenv, but also You can do it manually, wich were my choice.

1. Add repository from https://launchpad.net/~fkrull/+archive/deadsnakes

sudo add-apt-repository ppa:fkrull/deadsnakes && sudo apt-get update

If Your system dont have command add-apt-repository install it by typing
sudo apt-get install python-software-properties
2. Now You can choose what version to install.
2.3 2.4 2.5 2.6 2.7 3.1 3.2 3.3 3.4
sudo apt-get install python3.1 libpython3.1 python3.1-minimal 
Instead of 3.1 enter needed version.

3. To make system use Your installed python version, You have to make symlink to new installed python.

sudo unlink /usr/bin/python
sudo ln -s /usr/bin/python3.1 /usr/bin/python

Instead of 3.1 enter needed version.

Now just enter python --version
And enjoy new python enviroment.

UPDATE:

You will most likely meet problem with this problem:
Traceback (most recent call last): File "/usr/lib/command-not-found", line 10, in <module> import CommandNotFoundImportError: No module named CommandNotFound
To solve it (sort of) do as follows:

sudo nano /etc/bash.bashrc

And comment with #


# if the command-not-found package is installed, use it
#if [ -x /usr/lib/command-not-found -o -x /usr/share/command-not-found/command-not-found ]; then
#       function command_not_found_handle {
#               # check because c-n-f could've been removed in the meantime
#                if [ -x /usr/lib/command-not-found ]; then
#                  /usr/bin/python /usr/lib/command-not-found -- "$1"
#                   return $?
#                elif [ -x /usr/share/command-not-found/command-not-found ]; then
#                  /usr/bin/python /usr/share/command-not-found/command-not-found -- "$1"
#                   return $?
#               else
#                  printf "%s: command not found\n" "$1" >&2
#                  return 127
#               fi
#       }
#fi

pyenv+virtualenv on High Sierra

Install pyenv on Macos High Sierra brew update brew install pyenv brew install pyenv-virtualenv Install required python version: ...