awscli running with python 2.7 on OS x Sierra - python

I'm having an issue with my awscli version + python versions installed on my Mac.
After several tries following this I managed to have it working, however, if i run aws --version I get aws-cli/1.11.170 Python/2.7.10 Darwin/16.7.0 botocore/1.7.28
This confused me because I thought I had just installed python 3.6, so I decided to run which python, and it returned /usr/bin/python
I was still unsure and after some research I found this:
$which python3 /Library/Frameworks/Python.framework/Versions/3.6/bin/python3
Now i'm totally unsure which python version is the "main" one and if it is affecting my awscli, i plan to create a restapi using aws SDK with boto3 for Python.
How can i clean my python install or simply make sure my Mac is ready to work with the aws SDK + python?
PS.: I've tried this to uninstall python 2.6, 2.7 and 3.6 (currently installed on my system i suppose) but nothing really happened.
Thanks in advance for the help!

I would recommend creating a virtual environment to create an isolated environment for all the packages in your project. You can create a virtual environment of a specific python version using the following syntax in your shell:
$ python3.6 -m venv env
One you activate the virtual environment, you can use pip to install packages into your local python instance:
$ source env/bin/activate
(env) $ pip install awscli
Whenever you plan to run your application, or install packages for the project, simply activate the virtual environment.
For more information, see the documentation for the venv module in Python's standard library.

Related

How to change python3 version on mac to 3.10.10

I am currently running python 3.9.13 on my mac. I wanted to update my version to 3.10.10
I tried running
brew install python
However it says that "python 3.10.10 is already installed"!
When i run
python3 --version
in the terminal it says that i am still on "python 3.9.13"
So my question is, how do i change the python version from 3.9.13 to 3.10.10? I already deleted python 3.9 from my applications and python 3.10 is the only one that is still there.
I also tried to install python 3.10.10 from the website and installing it. However it does not work. Python 3.10.10 is being installed successfully but the version is still the same when i check it.
Python 3.10.10 is already installed along with Python 3.9.13. Your path is probably pointing to 3.9.13 and that's why you're getting that Python version.
Try modifying your path variable to point to brew's Python installation, or (better yet) make use of a virtual environment.
a) Telling what Python version your PATH variable is pointing to:
$ which python
Will tell you what's the actual executable's path. That way, you are going to see exactly where you main python resides.
b) If you want to create a virtual environment with brew's python try something like:
$ /usr/local/Cellar/python#3.10/3.10.1/bin/python3 -m venv py310
$ source venv/bin/activate
$ python
> # you should be inside a 3.10.1 envornamente
> CTRL+D
$ pip install requests
you can use pyenv to work with multiple python environments
things to do:
install pyenv : brew install pyenv
install particular python: pyenv install 3.10.10
set python3.10.10 to gloabal python env: pyenv global 3.10.10
and can start using python 3.10.10 version
Just delete the current python installation on your device and download the version you want from the offical website. That is the easiest way and the most suitable one for a beginner.

VSCode issue with setting python version to 3.10 on Azure function sample

I am trying to run the Azure python function with Fast API locally and hit into this issue
https://github.com/Azure-Samples/fastapi-on-azure-functions/issues/7
The last one suggests upgrading to the 3.10 version of python to solve the issue. However when i try to upgrade in vs code , i get the errors below
When i try to manually add the path
I am not that familiar with all python ENV setups, any suggestions will be helpful
EDIT:
Yes, Here are all the versions I have on the machine
Below are the python versions installed in my windows system:
When creating the Azure Function Python App in the VS code, it is not showing the Python 3.10.x version interpreter:
In this step, click on Skip virtual environment and create the required trigger function.
You can select the Python 3.10.x version interpret after creating the trigger function:
py -m pip install --user virtualenv
py -m venv env
.\env\Scripts\activate
py -m pip install -r requirements.txt
Run the above cmdlets to activate virtual environment taken, taken from the Python Packages Source.
So that you can be able to see the current python version for the current Azure Function in VS Code:

how should i be using python 3.6 and python 3.7 side by side on msys2 and cmder?

I'm using msys2 for my dev environment on Windows 10. It's great, and this is the first roadblock I've come up against.
Specifically I'm trying to install some packages that won't allow me to via pip because my platform is incorrect. They require a 3.6 platform and msys2 comes with 3.7
I tried pyenv-win, but that wouldn't seem to work within cmder and it also installed some full windows installers of python 3.6.
Is there a recommended way to get another version of python installed using the msys ecosystem of command lines?
I know you want to use msys2, but you should reconsider, the majority of implementation don’t use msys2. multiple versions and multiple environments can get complicated. If you choose to go forward in a more standard way, you could use what I have written below
You can’t create a virtual env with a version of python that isn’t install in your system.
Downloaded and install the version of python you want to use, from https://www.python.org/
Create a project folder
Create a venv calling the newly installed version of python
venv is part of the standard library
c:\>python -3.x -m venv c:\path\to\myenv
it created a copy of the python executable in the newly created venv
https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/
Activate the new env
c:\> c:\path\to\myenv\Scripts\activate.bat
(venv) path\to\myenv>
Once activated you can pip install
(venv) path\to\myenv> pip install [package.name]
(venv) path\to\myenv> pip list
Any script you run from that venv will used the python exe installed in that virtual environment and use the packages you just installed there

How to change Apache Airflow Python path from Python 2.7 to 3?

Initially, I had installed Apache Airflow and python 2.7 is set as default path. Now, I'm trying to change path from 2.7 to 3. Is it possible to do so or do I have re-install the airflow and set the python path? Any pointers would be helpful?
Thanks in advance!
There are a few ways to make sure that you are using the version of Python that you would like. Docker is one, take a look at https://github.com/puckel/docker-airflow for a good example.
Another is to use virtual environments. I've only used Virtualenv with success. I like Pipenv, but unfortunately I ran into some dependency-trouble using it with Airflow.
Anyways, here is an example of what should work with Virtualenv:
cd your-project
virtualenv -p python3 .direnv
source .direnv/bin/activate
pip install -r requirements.txt
python --version should list python 3, and running airflow webserver, should run Airflow in python 3.
I had installed Apache Airflow and python 2.7 is set as default path.
Use
pip3 install apache-airflow
instead of
pip install apache-airflow

Virtualenv installing modules with multiple Python versions

I am trying to start a Python 3.6 project by creating a virtualenv to keep the dependencies. I currently have both Python 2.7 and 3.6 installed on my machine, as I have been coding in 2.7 up until now and I wish to try out 3.6. I am running into a problem with the different versions of Python not detecting modules I am installing inside the virtualenv.
For example, I create a virtualenv with the command: virtualenv venv
I then activate the virtualenv and install Django with the command: pip install django
My problems arise when I activate either Python 2.7 or 3.6 with the commands
py -2 or py -3, neither of the interactive shells detect Django as being installed.
Django is only detected when I run the python command, which defaults to 2.7 when I want to use 3.6. Does anyone know a possible fix for this so I can get my virtualenv working correctly? Thanks! If it matters at all I am on a machine running Windows 7.
Create virtual environment based on python3.6
virtualenv -p python3.6 env36
Activate it:
source env36/bin/activate
Then the venv36 has been activated, venv36's pip is available now , you can install Django as usual, and the package would be stored under env36/lib/python3.6/site-packages:
pip install django
You have to select the interpreter when you create the virtualenv.
virtualenv --python=PYTHON36_EXE my_venv
Substitute the path to your Python 3.6 installation in place of PYTHON36_EXE. Then after you've activated, python executable will be bound to 3.6 and you can just pip install Django as usual.
The key is that pip installs things for a specific version of Python, and to a very specific location. Basically, the pip command in your virtual environment is set up specifically for the interpreter that your virtual environment is using. So even if you explicitly call another interpreter with that environment activated, it will not pick up the packages pip installed for the default interpreter.

Categories

Resources