Use pyenv local python version with SublimeREPL - python

My system comes with Python 2.7.6 installed by default. I need to use v2.7.8 so I've installed it using pyenv:
pyenv install 2.7.8
and set it up as the local version in the folder where my code resides with:
cd /path_to_folder
pyenv local 2.7.8
After this, I installed all the necessary packages into v2.7.8 using pip install <package>.
If I run:
$ cd /path_to_folder
$ python
I get the 2.7.8 version and I can run my code with no issues. But if I try to build my code within Sublime 3 using the SublimeREPL package I get the default 2.7.6 version where none of the packages are installed.
How can I force SublimeREPL to build using the 2.7.8 version of Python I installed via pyenv instead of the system default 2.7.6 version?

Related

Installing the same version of pyenv and boost_python

I have installed python by pyenv
$which python
/Users/whitebear/.pyenv/shims/python
$python -V
Python 3.7.9
However in /Users/whitebear/.pyenv/versions/3.7.9/lib/,there is no libboost_python**
So I installed by brew brew install python-boost.
It is installed in /usr/local/Cellar/boost-python3/1.75.0/
However there is only libboost_python39** and libboost_numpy39
My python version is 3.7.9 though.
How can I install boost_python for pyenv the same version??
Please see https://github.com/pyenv/pyenv/issues/585
You need to build boost against the python version you installed in your pyenv

Pyenv – enabling python3.7 command

I've just got a backend repository to launch locally. It uses poetry for the dependencies and has this specified python = ">=3.7,<3.8".
python -V -> Python 2.7.16
python3 -V -> Python 3.8.5
which python -> /usr/local/bin/python
which python3 -> /usr/local/bin/python3
I've installed pyenv using brew and installed 3.7.8 (which is now visible when running pyenv versions).
Running poetry shell throws me:
The currently activated Python version 3.8.5 is not supported by the project (>=3.7,<3.8).
And when trying to poetry env use 3.7.8 it returns:
/bin/sh: python3.7: command not found
My question is – how can I setup python3.7 command on my macOS?
It looks like there's no python3.7 executable linked explicitly by pyenv on your path.
You should enable 3.7.8 as the local version for your project by running: pyenv local 3.7.8 inside the project directory.
You could also tell poetry to use it directly by passing poetry env use the full executable path (not just the version string).

How do I deal with pip in different python versions?

I had python 3.8 installed and then I installed python 2.7. I am trying to run a python program with py -2 program.py in vs code using with python 2.7 as selected environment and I am getting an error, ImportError: No module named googlemaps even though I have already installed.
If I run the program using Python3 then it would run fine. Also when I open vs code using python 2.7 as selected runtime environment then I would get a warning Linter Pylint is not installed. If I click on install then I would get another warning There's no Pip installer available in the selected environment.
Also even though I have changed the python path from 3.7 to 2.7, default python version will still show up as 3.7 when I runPython in command line.
Things that I have tried to install the googlemaps module for python 2 after googling for solutions,
pip2 install googlemaps--upgrade
py -2 -m pip install googlemaps
If you have your python2 binary located, you can just call it directly:
/usr/bin/python2 -m pip install googlemaps
And if you're not sure where your python binary is, you can use
import sys
print(sys.executable)
to locate it.
And if you don't have pip, you should install it by downloading this file:
https://bootstrap.pypa.io/get-pip.py
then running:
/usr/bin/python2 get-pip.py
It is recommended to install Python 3.8 using Pyenv and also when you are using different versions of python, it is very useful
curl https://pyenv.run | bash
pyenv install 3.8.1
pyenv virtualenv 3.8.1 venv
pyenv local venv
with pyenv local you set your version for use.
If after this you run
pyenv version
It will output to 3.8.1
With regards to pip installation, run
whereis python
and if it outputs to
usr/bin/python2
then you can use pip for installing python2 packages and pip3 for packages compatible to python3.

How do I install python 3.6.5 on my Ubuntu 19.10 that already contains python 3.7.5?

I will accept two possible solutions:
Both versions are installed side by side.
3.7.5 is removed and 3.6.5 is then installed.
For this you can use pyenv.
https://realpython.com/intro-to-pyenv/
If you have installed all packages and dependencies you can install different version like this:
pyenv install -v 3.6.5

Installing Python using Homebrew

I'm currently following this guide to install python and its libraries onto my Mac OS. http://www.nyx.net/~mlu/pages/computing/installing_and_configuring/installing_and_configuring_Python_on_Mac_OS_X/#.WCLNgeErJE4
In step 4, I brew installed python and python3
Upon checking the path of python and python3, I found that python was in /usr/bin/python while python3 is in /usr/local/bin/python3
How do I get my python to install in /usr/local/bin?
UPDATE
Upon looking on my terminal, I can see that the brew install python had installed it in /usr/local/bin (version is 2.7.12) but somehow I am accessing a python that was installed in /usr/bin (version is 2.7.10). How do i fix this?

Categories

Resources