10/5/2023 0 Comments Linux see all python versions![]() Only a few of them technically answer the question's explicitly stated apt-get use-case, but the orthogonal answers are helpful to other readers (like me) as Docker-based answer pointed me in the right direction for my use-case and is greatly appreciated. Some great answers here with alternatives for almost every use-case (install from source, PPA's, pyenv, Docker, Conda). Note: you should probably be using a virtual environment like virtual env or conda/anaconda anyway unless your using docker anyway. This solution installs python 3.6 but I am sure if you look into it there you can get python 3.5 if thats what you want. For a docker example one can do: docker pull continuumio/anaconda3ĭocker run -i -t continuumio/anaconda3 /bin/bash Note: one can also just install Anaconda. It seems that was one of my problems because I was starting from a docker image from tensorflow (in particular gcr.io/tensorflow/tensorflow:latest-devel-p圓) and something in that image (I assume its that they already have python 3.4 but it might something else) didn't allow me to update my python to get python 3.5.Ĭredit: I discovered this when I asked the following: Important Note: it seems that if you already have python 3.4 installed then apt-get install python3 does not work because it says you already have it. Then for some reason it needed to update some ubuntu stuff so I did (inside the container): apt-get update & apt-get install -y build-essential git libjpeg-devĪnd then I simply installed python3 and it seems it automatically got python 3.5: apt-get install python3Īnd to test if pip works lets download something: pip3 install tensorflow How do I install a different Python version using apt-get?Īs far as I can tell, at least in a docker container, one can definitively apt-get python 3.įirst I ran into a ubuntu container with container: docker run -it -rm ubuntu:latest bash.Which sets the Python version to the correct one. Now, when someone wants to use your project, they will do: pyenv local ![]() python-version containing the version string.Īnd now let's install a package locally just for our project: TODO: there is no nice way it seems: Then, from inside your project directory, set the desired python version with: pyenv local 3.8.0 This is how to do it.įirst install your desired Python version as before. However, what you usually want is to set a specific python and package version on a per-project basis. In the previous section, we saw how to use pyenv in a global setup. The global version is somethow determined by: ~/.pyenv/version We see that which python points to: ~/.pyenv/shims/pythonīecause ~/.pyenv/shims is prepended to PATH with the rc scripts. We can confirm that everything is locally installed in our clean environemnt with: python -c 'import cowsay print(cowsay._file_)' Python -c 'import cowsay cowsay.tux("Python is fun")' We can now proceed to install and use packages normally: pip install cowsay Select a different python version: pyenv global 3.8.0 We now have: * system (set by /home/cirsan01/.pyenv/version) List available Python versions: pyenv versions # Build and install a Python version from source. Xz-utils tk-dev libffi-dev liblzma-dev python-openssl git Libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \ Sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \ Install the python version you want: # Increase the chances that the build will have all dependencies. bashrc: export PATH="$/.pyenv/bin:$PATH"įind Python version to install: pyenv install -list Pyenv allows you to manage multiple Python versions without sudo for a single user, much like Node.js NVM and Ruby RVM. This method does not use apt-get, but it is, I believe, the best option available today, as it can easily compile any Python version from source for you, so you don't have to rely on any PPAs. Step 4 – Check the Python VersionĬheck the latest version installed of python using below command. Make altinstall is used to prevent replacing the default python binary file /usr/bin/python. Use below set of commands to compile python source code on your system using altinstall. You can also download latest version in place of specified below. Sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-devĭownload Python using following command from python official site. sudo apt-get install build-essential checkinstall Use the following command to install prerequisites for Python before installing it. ![]() Just follow this steps (tested) : Step 1 – Install Required Packages
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |