How to switch AWS CLI to Python 3.7 on macOS? - python

On macOS Mojave 10.14.6, have the following versions of python installed:
Python 2.7.16
Python 2.7.16 (default, May 17 2019, 18:32:33)
[GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.46.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Python 3
Python 3.7.4 (v3.7.4:e09359112e, Jul 8 2019, 14:54:52)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Installed AWS CLI using these steps:
curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
unzip awscli-bundle.zip
sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
Now, when I test aws from the command line using aws --version
aws-cli/1.16.247 Python/2.7.16 Darwin/18.7.0 botocore/1.12.237
Question(s):
Is this correct?
Is it supposed to be using Python 3.7.4 instead?
If so, how can I switch this over?

By default the installer will use whatever is in your path for python.
If you want to use Python 3, you need to run something like this to run the installer:
sudo /usr/local/bin/python3 awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
Replace /usr/local/bin/python3 with your path for Python 3 if it's different.
All of this said, if you have both Python environments installed, I'm not aware of any reason to prefer one version over the other for the AWS CLI tool.

Related

why is pyenv still prioritizing the system's python version when I run `python3.x`?

I have pyenv installed and everything works pretty well except for one aspect: when I run the command python3.9, my system still points to my system's version of python (3.9.13). However, I would like to make it point to my pyenv installed version when running python3.9:
❯ pyenv versions
system
3.7.10
3.8.10
* 3.9.5 (set by /Users/username/.python-version)
❯ python3
Python 3.9.5 (default, Jul 7 2022, 20:35:58)
[Clang 13.1.6 (clang-1316.0.21.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
❯ python3.9
Python 3.9.13 (main, May 24 2022, 21:13:51)
[Clang 13.1.6 (clang-1316.0.21.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
❯ python3.9 --version
Python 3.9.13
❯ python3 --version
Python 3.9.5
Note that the issue occurs just when running python3.9, not python3.
What's wrong in my configuration?

How can I install data.table on my fedora distro

Looking at this github I'd like to be able to install datatable.
I do run a fedora 26 distro that runs python3.6
statquant  ~  python3
Python 3.6.4 (default, Mar 13 2018, 18:16:01)
[GCC 7.3.1 20180130 (Red Hat 7.3.1-2)] on linux
Type "help", "copyright", "credits" or "license" for more information.
When I try to install it I get:
statquant  ~  pip install https://s3.amazonaws.com/h2o-release/datatable/stable/datatable-0.3.2/datatable-0.3.2-cp36-cp36m-linux_x86_64.whl
datatable-0.3.2-cp36-cp36m-linux_x86_64.whl is not a supported wheel on this platform.
Is this expected ?
I am totally new to python
Currently Python datatable distributes pre-built binaries for the following platforms:
MacOS
CentOS Linux (linux_x86_64)
PowerPC Linux (ppc64le)
For all other platforms, you would have to clone the repository and manually build from source.

With Python 2.7.15 on a MAC console, virtualenv creates an environment with a different version of Python

Here is an extract of my console in a Mac, as you can see the Python on the console is 2.7.15 but on the environment it becomes 2.7.10 which is an older version... any help on why and how to fix it would be most welcomed!
dhcp-18-57:Wakeup6 **jbs$ python**
**Python 2.7.15** (default, May 1 2018, 16:44:14)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
dhcp-18-57:Wakeup6 jbs$ virtualenv env
New python executable in /Users/jbs/PycharmProjects/Wakeup6/env/bin/python
Installing setuptools, pip, wheel...done.
dhcp-18-57:Wakeup6 jbs$ source env/bin/activate
(env) dhcp-18-57:Wakeup6 **jbs$ python**
**Python 2.7.10** (default, Oct 23 2015, 19:19:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
If you installed python using Anaconda, then set up a new virtual environment for python 2.7.15 Then following directions in the Anaconda documentation, activate this virtual environment and you should be good to go.
If you didn't use Anaconda, just follow the directions for setting up a virtual environment on a Unix box. Then activate that environment and start working.
You can have multiple versions on your computer. Virtual environments allow you to run the version you want. I have virtual environments for python 2.7.13 and python 3.6.
If this doesn't work please let me know. I'll try to help.
Thank you all for your input. I finally figured out how to solve it. The difficult part was finding out how to locate the place where python 2.7.15 was installed which I'll leave intact in the response since I found it by trial and error looking in other places. I have not found a command that gives you the full path (perhaps an expert can tell us how to go from the laconic which python to the full path).
What I find interesting is that it does not really matter what the console uses when calling virtualenv. What matters is the version of Python used to install virtualenv which is the default version that will be used.
Essentially one has to use the -p option in virtualenv and make sure to find the right location where the desired version of python is.
dhcp-18--41:WakeUp8 jbs$ virtualenv -p /usr/local/Cellar/python#2/2.7.15/bin/python env
Running virtualenv with interpreter /usr/local/Cellar/python#2/2.7.15/bin/python
New python executable in /Users/jbs/PycharmProjects/WakeUp8/env/bin/python2.7
Also creating executable in /Users/jbs/PycharmProjects/WakeUp8/env/bin/python
Installing setuptools, pip, wheel...done.
dhcp-18-189-34-41:WakeUp8 jbs$ python
Python 2.7.15 (default, May 1 2018, 16:44:14)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
dhcp-18--41:WakeUp8 jbs$ pwd
/Users/jbs/PycharmProjects/WakeUp8
dhcp-18-189-34-41:WakeUp8 jbs$ source env/bin/activate
(env) dhcp-18-189-34-41:WakeUp8 jbs$ python
Python 2.7.15 (default, May 1 2018, 16:44:14)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

can't detect default python version

~$ python
bash: python: command not found
while running python2 and python 3 its showing different versions.
~$ python2
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
~$ python3
Python 3.4.0 (default, Jun 19 2015, 14:20:21)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
i think somehow default python link is broken. i can't seem to access ubuntu software center also.
Please suggest a way to fix this.
Rather than re-creating the simlink as suggested, I would start working with virtualenv. You can create virtual environment pointing at different python versions by doing:
virtualenv -p /usr/bin/python2 venv_name (for Python 2.7)
virtualenv -p /usr/bin/python3 venv_name (for Python 3)
Once you go into the venv and do the source venv_name/bin/activate, your python symbolic link will be pointed at the version you've chosen when creating it.
Also, you might find a pyvenv link which will be associated to Python 3 as this version of Python comes with virtualenv (and pip) out of the box. You might need to install virtualenv with pip (or easy install), and to figure it out which Pythonversion is your pip associated to, you can do pip --version

MacPorts on Snow Leopard: Python install seems to succeed but doesn't install a non-system Python

I've installed Python via MacPorts. According to this question, the files in /opt/local/bin should run the "correct" Python version. However, all those files are symlinks to:
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/
Running them directly from that folder (using no symlinks) runs an Apple build of Python!
Python 2.6.6 (r266:84292, Jan 6 2011, 13:25:25)
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
For comparison, running /usr/bin/python shows a slightly different version:
Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
They're both Apple builds! How do I install the correct version?
There are no "Apple builds" except the system Python (which is 2.6.1 on Snow Leopard, afai can deduce). The ports install seems to have worked as expected in this case. The reference to Apple is a reference to which GCC that was used.
I think it is running the build you want.
macports install every thing in /opt/local. So /opt/local/bin/python is a macport distribution.
/usr/bin/python is pre-install python distribution that comes with mac os x.
The following line, is an information about gcc build which is used for building macport python distribution.
[GCC 4.2.1 (Apple Inc. build 5664)]
If you have multiple versions of macport python installed, you can select the version using python-select
sudo port install python-select sudo
python-select python26
Also to ensure that you use macport python you could add the following to the PATH
export PATH=/opt/local/bin:$PATH

Categories

Resources