I'm using Ubuntu 14.04, with Python 3.4.3. I want to install the latest version of ansible-lint that is supported on that Ubuntu version and with this Python version.
One of the dependencies of the ansible-lint package is ansible.
When I simply use pip3 install ansible-lint I install for me a version of ansible that is not supported - since if I run ansible-lint --version I get the following error:
Ansible requires a minimum of Python2 version 2.6 or Python3 version 3.5. Current version: 3.4.3.
So how can I make sure that pip3 install the correct version with the correct versions of the dependencies?
From the documentation:
Python-3.5 was chosen as a minimum because it is the earliest Python-3
version adopted as the default Python by a Long Term Support (LTS)
Linux distribution (in this case, Ubuntu-16.04). Previous LTS Linux
distributions shipped with a Python-2 version which users can rely
upon instead of the Python-3 version
Also specifically:
However, if you happen to be testing Ansible code with Python-3.4 or
earlier, you will find that the byte string formatting here won’t
work. Upgrade to Python-3.5 to test.
In short it seems like no version of ansible is good on python 3.4 - you should upgrade to at least 3.5. If you don't want to change the system-wide version, look into creating virtual environments for this project.
Related
I have a Raspberry Pi 3 with Raspbian and I upgraded python version from 3.7 to 3.8. If I type python --version in the terminal the correct version appears as the system version. However none of the modules that I have installed AFTER the version change seem to work. Python gives ModuleNotFoundError when trying to import ANY of the modules that I have installed.
I can see the modules with pip freeze but Python seems to not be able to find them.
I followed this instructions to purge 3.7. I reinstalled pip after purging python 3.7 but pip as again installed in /home/pi/.local/lib/python3.7/site-packages/pip. How can I get rid of 3.7 completely?
python3.8 -m pip install SomePackage # specifically Python 3.8 should work.
More documentation here: https://docs.python.org/3/installing/index.html#work-with-multiple-versions-of-python-installed-in-parallel
Just to summarize the comments and suggestions from other answers:
The problem I have was caused by the fact that even I had set Python 3.8 as default and python -v was pointing to Python 3.8 the pip script was installing modules for Python 3.7.
The suggested solution was to use pip3.8 (or whatever version someone might have) to install packages for that equivalent Python version and that works good.
Ideally best option if someone wants to have multiple versions of python is to use pyenv. You can create multiple virtual environments with multiple python versions.
However Do not uninstall the default Python. I have also tried to uninstall the default Python 3.7 to avoid having two versions of python 3 and keeping track of which module is installed where. This was a bad idea. I did not know that many Linux distributions have applications which use the default Python. You might get a black screen and who knows what other problems see this discussion Removed Python 3 on 18.04, how can I fix my system?
I am using anaconda and my current python version in it is Python 3.7.10.
I want to upgrade everything: anaconda, the python version (which includes a major version upgrade to 3.8, I read somewhere that that matters), and all anaconda packages within I want to upgrade too.
I want to do this in my base anaconda env i.e. just upgrade everything.
Of course I can do this by uninstalling and then downloading latest version and installing anaconda again. But I want to avoid complete reinstallation.
I was reading the answers here
Upgrade to python 3.8 using conda
but it's not clear to me... how does one do this update in his base env?
Side question: I see version 3.9.2 for Python available here: https://anaconda.org/anaconda/python but the current full download of anaconda includes just Python 3.8. Why is that difference?
How can I do so that I have the latest and greatest of all packages (incl. the python interpreter)? Should I go for Python 3.8 or 3.9? I guess if I install 3.9 some anaconda packages might not work, is that so?
I am trying to setup Python 3 on my mac computer and I seem to have many versions of pip on my computer, not sure which I should be using.
When I run pip --version in the terminal I get pip 19.2.3 from /Library/Python/2.7/site-packages/pip-19.2.3-py2.7.egg/pip (python 2.7) which I am fairly certain is just the version that comes with mac os.
When I run python3 -m pip --version I get pip 20.1.1 from /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip (python 3.7)
When I run pip3 --version I then get pip 19.0.3 from /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/site-packages/pip (python 3.7)
I was hoping somebody could explain the differences between
The first and third pips seem to be from the OS (assuming you're on Catalina?) and the second one seems to be the one you've installed.
See
https://docs.python.org/3/using/mac.html
and
Python 3.7.3 Inadvertently Installed on Mac OS 10.15.1 - Included in Xcode Developer Tools 11.2 Now?
The quick and nasty answer is each installation of python can have its own pip, which in turn will have a different pipenv. This is all based off of your path. Most people opt to use virtualenv to create an app specific python environment so as to not impact other python applications which depend on specific conflicting versions.
I've searched a while and haven't found an answer to this particular issue.
brew info python returns python: stable 3.7.7 (bottled), HEAD
However, python -V and python3 -V return Python 3.6.1 :: Anaconda 4.4.0 (x86_64)
Why is my Mac python version different than what I've installed with HB, and how can I fix it? Thank you!
One version of python was installed using the Anaconda distribution. The other by Homebrew. It's not surprising that they are different versions. You should run in virtual environments and then you won't need to worry about 2 versions. Using the Anaconda distribution it is easy to set up a virtual environment to run that version.
Erg. Yes—this is a challenge sometimes. macOS ships with python as part of its system. Catalina 10.15.4 ships with /usr/bin/python3 of 3.7.3. brew (at the moment) has installed 3.7.7 as its stable branch, but it also offers a python#3.8 which installs 3.8.2. That's significant because there are other brew packages (notably vim) which specity python#3.8 as a dependency. Yuck.
I'm not running anaconda at the moment, but I'll take your word that it's yet-another version.
Whichever appears first in your path is going to prevail unless you're operating inside a context like a virtual environment. You can arrange your path to set your preferred python3 to run. You can always check which python3 is running by using "which python3" and that will give you the full path of the running program.
Word of caution: Each distinct python3 will maintain its own packages library. Once you have your paths sorted out, you should manage your packages with "python3 -m pip " to be sure you're managing the libraries for your intended version.
And yes—eventually, it'd probably be good for us to work in virtual environments or skip straight to Docker containers.
I'm new to programming and following a course where I must install Tensorflow. The issue is that I'm using Python 3.8 which I understand isn't supported by Tensorflow.
I've downloaded Python 3.6 but I don't know how to switch this as my default version of python.
Would it be best to set up a venv using python 3.6 for my program and install Tensorflow in this venv?
Also, I using Windows and Powershell.
Tensorflow is only supported until python 3.7 as of now.
You can check it here: https://www.tensorflow.org/install/pip
But there is a way to install it on Python3.8, just run the below command that will do your job:
python -m pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.12.0-py3-none-any.whl
This command work on mac and windows both, I haven't tested on Linux.
You should always use venv because by default every project on your system will use these same directories to store and retrieve site packages (third party libraries). At first glance, this may not seem like a big deal, and it isn’t really, for system packages (packages that are part of the standard Python library), but it does matter for site packages.
Consider the following scenario where you have two projects: ProjectA and ProjectB, both of which have a dependency on the same library, ProjectC. The problem becomes apparent when we start requiring different versions of ProjectC. Maybe ProjectA needs v1.0.0, while ProjectB requires the newer v2.0.0.
You can also take a look at anaconda, it’s the most populasr data sciencie platform and will be easy for you install tensorflow and jupiter notebook in just 2 clicks. Anaconda
Uninstall all your python versions and use the latest anaconda.
$ conda create --name tensorflow python=3.5
This way you create a virtual environment with python 3.5 which is supported by tensorflow.
So now you can install it.
$ activate tensorflow
(tensorflow) $ pip install tensorflow
it would have been nice if you would have the share the error screenshot
though as per i got the case
tensorflow work in both 3.8 and 3.6 just you have to check that you have 64bit version not 32 bit
you can acess both version from thier respective folder no need to install a venv
If you don't want to use Anaconda or virtualenv, then actually multiple Python versions can live side by side. I use Python38 as my default and Python35 for TensorFlow until they release it for Python38. If you wish to use the "non-default" Python, just invoke with the full path of the python.exe (or create a shortcut/batch file for it). Python then will take care of using the correct Python libs for that version.
Worked on Python 3.8.2 (default, Mar 05 2020, 18:58:42) [GCC] on linux
pip3 install --upgrade tf-nightly
Python Versions 3.5 - 3.8 are supported now.
You can verify on this page:
https://www.tensorflow.org/install/pip