Can someone please tell me how to downgrade Python 3.6.9 to 3.6.6 on Ubuntu ? I tried the below commands but didnot work
1) pip install python3.6==3.6.6
2) pip install python3.6.6
First, verify that 3.6.6 is available:
apt-cache policy python3.6
If available:
apt-get install python3.6=3.6.6
If not available, you'll need to find a repo which has the version you desire and add it to your apt sources list, update, and install:
echo "<repo url>" >> /etc/apt/sources.list.d/python.list
apt-get update
apt-get install python3.6=3.6.6
I advise against downgrading your system python unless you're certain it's required. For running your application, install python3.6.6 alongside your system python, and better yet, build a virtual environment from 3.6.6:
apt-get install virtualenv
virtualenv -p <path to python3.6.6> <venv name>
One option is to use Anaconda, which allows you to easily use different Python versions on the same computer. Here are the installation instructions for Anaconda on Linux. Then create a Conda environment by running this command:
conda create --name myenv python=3.6.6
Obviously your can use a different name than "myenv". You can then activate the environment in any terminal window:
conda activate myenv
Then you can pip install any packages you want. Some basics of anaconda environments can be found on the website's getting started page.
Related
Hey everyone I installed Python3.9 on my Mac using homebrew package manager but now I do not know how to install packages to it for use
Can anyone please tell me, thanks !
You should first do some research on the Python virtual environment, but the final answer to your question is to use pip install for installing Python packages. Be aware that there are other options out there, but pip is the most prevalent.
When you installed python, it has pip installed by default. pip comes with python. You can check pip version by
pip --version
OR
pip3 --version
Now, in order to install any other package, you can install by
pip install <package-name>
It would be better if you install a virtual environment, and install all other packages inside the virtual environment so that you can install packages according to your project requirements and with different versions.
To install virtual environment, do
pip install virtualenv
Once the virtual environment is installed, you can create your virtualenv according to your project requirement by:
virtualenv -p python3 venv
Here venv is your virtualenv name. To activate it,
source venv/bin/actiavte
Now, you can install all your required packages inside this virtualenv by pip3 install <package-name>. This will keep it separated from your system environment.
I am trying to properly install python and set up virtual environments to make project development easier. Im stuck on how to install pip now. My question is this:
Do I need to install pip in a specific way if I'm trying to set up virtual environments?
Here's what I've done so far...
installed pyenv
used pyenv to install python version 3.7, 3.8 and 3.9
set global pyenv to be python 3.9
Now I don't know hot to set up pip.
I did this:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
and then:
python get-pip.py
..however when I go to verify pip was installed i get 'pip command not found'.
How do I properly set up pip so that I can create virtual environments and install packages for different environments?
Do I need to add pip to my PATH? If so, how do I do that?
You can create virtual environment directly from python with venv
(documentation: https://docs.python.org/3/library/venv.html)
Example:
python3 -m venv /path/to/new/virtual/environment
Activate the virtual environment
source /path/to/new/virtual/environment/bin/activate
Then you can install any package with
pip package-to-install
Context: I have python 3.7 on my computer (Linux). Some package (tensorflow) needs a previous version of python to function.
In this post, a user suggested to install a previous version of python using the command:
conda install python=3.6
I am confused by this command, since I normally install python using apt or apt-get ( I am on ubuntu ). I think of python as being separate from anaconda.
apt install python=3.6
What is the difference between these two commands?
What you might want to do if you need a specific version of Python for a particular project is making a 'virtual environment'. Basically, that means that pip packages are installed within the project folder rather than in your bin folder somewhere on your computer. Virtual environment can also link to a version of python using something like virtualenv --python=/usr/bin/python2.6.
apt install python=3.6 will install in the standard bin folder of your distro.
conda install python=3.6 will check in which environment you currently are and install it there. It of course requires Anaconda installed and setup on your computer.
There are a lot of virtual environment management packages out there and I am not going to give an opinion on which is the best.
Note that if you install it using apt install, the version used in command line for python3 or python may be ambiguous, to be sure, you can specify the full path or make an alias for that path if there isn't one.
I am using Anaconda Python 3.4 on a Windows 7 PC now. Recently I am trying to follow the instruction of the book High Performance Python to learn some profiling skills. To this end I need to use pip install to install several tools. Unfortunately, not all of them support Python 3, and I have to install Python 2.7 now.
Before installing Python 2.7, I would like to know how I should handle with such 2.7/3.4 coexisting system? How do I setup pip so that I could use pip install to install packages for different Python versions separately?
You can create a conda environment via:
conda create --name py27 python=2.7
and use this environment for your work with Python 2.7. Activate it with the command activate py27, going back to your root environment is just activate.
In the py27 environment you can install pip and all other packages you need.
pip is generally located at the Python27\Scripts and/or Python34\Scripts folder. If you wish to invoke pip directly in the command line, these folders should be in your PATH environment variable.
Now I would just rename pip.exe in Python34\Scripts into any other name, for example pip_for_3.exe. That way, when I install packages for Python27, I would just use:
pip install <package name>
and packages for Python34:
pip_for_3 install <package name>
Coexisting Python installations are not a problem, you just have to know which version is invoked every time. See this answer for the same idea.
I've setup anaconda and created a python 3.3 environment. Now I wanted to install some package (dataset). The install instructions ask to clone the git repo and run
python setup.py install
but now the packages are not installed to the environments site-packages folder but to a different anaconda location.
What are the normal steps to solve that problem? Newbie-compatible solutions are preferred. The OS is MacOSX, just is case, it is relevant.
It looks like conda automatically adds pip to your conda environment, so after you source your conda environment, i.e.:
source activate ~/anaconda/envs/dataset
you should be able to install it like this:
git clone git://github.com/pudo/dataset.git
pip install ./dataset
EDIT
Here are the exact steps I took:
$ conda create -p ~/anaconda/envs/py33 python=3.3 anaconda pip
$ source activate ~/anaconda/envs/py33
$ which pip
~/anaconda/envs/py33/bin/pip
$ pip install ./dataset/