how to could i set pythonhome - python-3.x

i am new to python3 i don't know how to set PYTHONHOME in ubuntu 16.04.
i tried whereis python it show like below
this many version it show. from this how can i set pythonhome for python3.x
sysadmin#localoffice:~$ whereis python
python: /usr/bin/python /usr/bin/python3.5 /usr/bin/python2.7
/usr/bin/python3.5m-config /usr/bin/pythnfig
/usr/bin/python3.5m /usr/lib/python3.5 /usr/lib/python2.7
/etc/python /etc/python3.5 /etc/python2local/lib/python3.5
/usr/local/lib/python2.7 /usr/include/python3.5
/usr/include/python3.5m
/usr/share/usr/share/man/man1/python.1.gz
sysadmin#localoffice:~$ echo ${PYTHONPATH}
sysadmin#localoffice:~$

Try:
alias python /path/to/your/python/home
e.g:
alias python /usr/bin/python2.7

Related

Homebrew python taking precedence over venv python

I have a few questions related to Python paths. I used homebrew to install python3 on my Mac:
# homebrew python
> which -a python
python: aliased to /usr/local/bin/python3.9
# system python
❯ which -a python3
/Library/Frameworks/Python.framework/Versions/3.7/bin/python3
/usr/local/bin/python3
/usr/bin/python3
/Library/Frameworks/Python.framework/Versions/3.7/bin/python3
I then set up a virtual environment using the command python -m venv venv. After activating it, I get:
> which -a python
python: aliased to /usr/local/bin/python3.9
/Users/kshitijsachan/Documents/venv/bin/python
> which -a python3
/Users/kshitijsachan/Documents/venv/bin/python3
/Library/Frameworks/Python.framework/Versions/3.7/bin/python3
/usr/local/bin/python3
/usr/bin/python3
/Library/Frameworks/Python.framework/Versions/3.7/bin/python3
My questions are:
Why does homebrew python take precedence over the venv python when I run which -a python with the venv activated?
Why is /Library/Frameworks/Python.framework/Versions/3.7/bin/python3 listed twice under which -a python3?
Is this the canonical setup for venv's with Homebrew python?

python venv creates a not-empty venv

I don't know much about python virtual environments so any help would be appreciated.
In my .bash_profile file there is an alias:
alias python='python3'
So I always use "python" command instead of "python3" command.
But, in terminal when I run:
$ which python
/usr/bin/python
$ which python3
/Library/Frameworks/Python.framework/Versions/3.7/bin/python3
I don't know why are they different, and when I create a virtual environment with:
$ python -m venv myvenv
It doesn't create a venv with just "pip" and "setuptools" packages, otherwise it does OK when a run with:
$ python3 -m venv myvenv
Has anybody know what happend?
Many thanks!

How is the default usage of pip2 in Manjaro?

I'm a bit confused about the default usage of pip2 in Linux Manjaro.
Python2 and Python3 are installed by default as well as pip (for python3).
$ python --version
Python 3.7.4
$ python2 --version
Python 2.7.16
$ pip --version
pip 19.0.3 from /usr/lib/python3.7/site-packages/pip (python 3.7)
But pip2 fails
$ pip2 --version
bash: pip2: command not found
I'm sure i can install pip2 via pacman, but whats the initial intention to roll out python2 without a depending pip2 version?
Or did i simply missing something here?

Virtualenvwrapper does not initialize after updating Python to 3.6

My OS (Arch Linux) recently updated Python from 3.5.2 to 3.6.0, now when running any terminal I get this message:
/usr/bin/python: Error while finding module specification for 'virtualenvwrapper.hook_loader' (ModuleNotFoundError: No module named 'virtualenvwrapper')
virtualenvwrapper.sh: There was a problem running the initialization hooks.
If Python could not import the module virtualenvwrapper.hook_loader,
check that virtualenvwrapper has been installed for
VIRTUALENVWRAPPER_PYTHON=/usr/bin/python and that PATH is
set properly.
Moreover I get these outputs
$ whereis python
python: /usr/bin/python3.6 /usr/bin/python3.6m /usr/bin/python3.6-config /usr/bin/python3.6m-config /usr/bin/python2.7-config /usr/bin/python /usr/bin/python2.7 /usr/lib/python3.6 /usr/lib/python3.5 /usr/lib/python2.7 /usr/include/python3.6m /usr/include/python2.7 /usr/share/man/man1/python.1.gz
$ which python
/usr/bin/python
$ python --version
Python 3.6.0
How can I fix this situation? Will this situation will have any impact on my created virtual envs or other programs?
Thanks in advance.
This article was very useful to solve the situation, only you need is to run:
$ sudo pip3.6 install -U pip
$ sudo pip3.6 install -U virtualenvwrapper

Making 2.7.3 default version of python on CentOS 6

I want to execute python from php and I do have a script that works fine for default python interpreter. I have centos with default python 2.6.6 which is installed at /usr/bin/python and python 2.7.3 which is installed at /usr/local/bin/python2.7. You can see what is the default python version:
[root#me ~]# python -V
Python 2.6.6
[root#me ~]# python2.7 -V
Python 2.7.3
How do I make python 2.7.3 default python on my OS. So when i run python -V i should get 2.7.3?
I know it is bad. The alternative is to uninstall python 2.7.3 and I do not know how to do this.
Execute the below commands to make yum work as well as python2.7
echo "export PATH="/usr/local/bin:$PATH"" >> /etc/profile
source /etc/profile
mv /usr/bin/python /usr/bin/python.bak
update-alternatives --install /usr/bin/python python /usr/bin/python2.6 1
update-alternatives --install /usr/bin/python python /usr/local/bin/python2.7 2
update-alternatives --config python
sed -i "s/python/python2.6/g" /usr/bin/yum

Resources