I am trying to use tensorflow but my python is to recent. I have python3.7.2 and I need py3.6 in order to install and use tensorflow.
I have installed py3.6.8 but I still can't install it with pip. Is there a way of interchanging between versions of python to install/use tensorflow. Or is it to do with my pip version?
The error is:
Could not find version that satisfies the requirement tensorflow in versions:
The main problem is that I don't know how to get tensorflow. Can someone help me do this?
By far the best option will be to use Anaconda virtual environment. After you install Anaconda, use environments to manage different versions of Python:
Python 3.6.8:
conda create -n myenv python=3.6.8 tensorflow
Python 3.7:
conda create -n myenv python=3.7 tensorflow
Why am I saying it's best with Anaconda? Long story short, it can be (much) faster. Here's an article that discusses why.
Option 1:
Install multiple versions in separate directories, and then you run the python program with the Python version you want to use. Like so:
C:\Python26\Python.exe thescript.py
What virtualenv does is that it gives you many separate "virtual" installations of the same python version. That's a completely different issue, and hence it will not help you in any way.
Option 2:
Use Pythonbrew.
Once pythonbrew is installed:
#to install new python versions is as simple as:
pythonbrew install 2.7.2 3.2
#to use a particular version in the current shell:
pythonbrew use 3.2
#to uninstall:
pythonbrew uninstall 2.7.2
Related
I'm relatively new on dealing with python libraries so it might be a stupid question but here is the detailed problem:
I'm working on Linux and trying to use a python program (ORF-rater) using python 3.7. Unfortunately, when I run the program, I get the following error:
ImportError: cannot import name 'maketrans' from 'string'
which I think is related to this issue. Therefore I want to use another version of Python (3.4 or 2.7 for instance) that will support this maketrans.
The program that I'm using also uses the Python package plastid, which I installed using Conda conda install -c bioconda plastid which I guess worked well.
However, it installed the package on python 3.7 only, and I can't find a way to install for python 3.4 (I tried others things as pip3.4 install plastid, but it did not work, most likely because I'm working on an university server and I don't have permission to do it).
In brief, how do I install a package using Conda for a specific version of Python (3.4)?
The following code creates an environment with a specific python version (2.7 since 3.4 was not an option), then you activate it and install the package you need.
conda create -n test python=2.7
conda activate test
conda install -c bioconda plastid
python
Then in Python, I did the following and got no errors
from string import maketrans
2 Versions of Python 3.9 and 3.8.6 are installed on Win 10. I Also want Tensorflow installed. But Pip recognises only Py 3.9 and hence does not installs tf locally. Is there a way out for this.
Try this command
python -m pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.12.0-py3-none-any.whl
python -m pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.12.0-py3-none-any.whl
This work with my python 3.9
The following command should be work for python version 3.9:
python -m pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.12.0-py3-none-any.whl
For dealing with multiple Python Versions it is highly recommended to use virtual environments. It makes live much easier. For a detailed guide how to set them up read this: https://www.freecodecamp.org/news/manage-multiple-python-versions-and-virtual-environments-venv-pyenv-pyvenv-a29fb00c296f/
This worked for me:
python3.8 -m pip install tensorflow
I think pip uses the latest python version, so you have to tell pip to install with python3.8 or use the beta version of tensorflow:
pip install tf-nightly
Change you're Environment variable from python 3.9 to python 3.8.6 .
1.search for environment variables in your pc see the pic --->.
Environment variables
2.Now select environment variables option see pic --->.
click on option
Now edit the path of wanted python see pic --->.
Edit
Your system is defaulting to python 3.9 because it is higher up in the system path list, so it is seen first.
search for environment variable in windows then click on environment variable. Then under system variable, search for path and then move the python3.8 higher up than python3.9.
Your system will now see 3.8 as default.
I did two things to make it work.
After pip install tensorflow, restarted my VS Code
Change the interpreter from 3.9 to 3.7, so it started installing ipython relevant packages and then changed it back to 3.9.
I'm trying to install numpy, matplotlib, and scipy in the right python version.
Initially I was testing with different python versions (3.2, 2.7, 2.6).
I removed all these versions using: How to uninstall Python 2.7 on a Mac OS X 10.6.4?
Afterwards, I reinstalled Python 2.7.11.
when I try to install numpy, matplotlib and scipy, using pip, I get the following message:
Requirement already satisfied (use --upgrade to upgrade) ...
In my terminal, I tried the following:
$ which python
/Library/Frameworks/Python.framework/Versions/2.7/bin/python
$ python
Python 2.7.11 (v2.7.11:.....)
.....
>>> import numpy
ImportError: No module named numpy
$ /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python
Python 2.7.10 (default, ......
.....
>>> import numpy
>>> numpy.__version__
'1.8.0rc1'
for some reason these packages got installed in 2.7.10 and not 2.7.11, which is the version I downloaded from python.org. Also, I don't even know how I got the 2.7.10 version.
How can I fix this issue?
You can also use macports (https://www.macports.org/) to install different versions of python, numpy, and matplotlib. It's really quite simple.
Alternatively, you can perhaps use anaconda (https://www.continuum.io/downloads), which uses conda, to achieve your goal.
I recommend using virtualenv (with virtualenvwrapper: https://virtualenvwrapper.readthedocs.org). It is very easy to setup and you'll have absolutely no problems in future when you deal with multiple Python installations.
I work with virtualenv for years now and create for each project a separate virtual environment, which is always clean and I never have to deal with PATH, PYTHONPATH or whatever.
If you followed the virtualenvwrapper installation guide, you can simply create for example one virtualenv for everyday work via:
mkvirtualenv common -p /Library/Frameworks/Python.framework/Versions/2.7/bin/python
this will create the virtualenv and automatically activate it, so you can instantly install the packages you want:
pip install matplotlib numpy scipy
and every time you want to use it you type:
workon common
As you see above, you can specify the python executable via the -p flag. Each virtualenv will be a completely fresh and independent Python installation where you can use pip to install whatever you want (without root access of course).
It is likely to mean that you used pip or easy_install from another python version.
When you install your modules, make sure to use the correct pip version.
It might be /usr/local/bin/pip2.7 for example.
If you install Anaconda from continuum.io, you'll get access to versions of many packages that have been tested to work with the version of Python that you are interested in working with. Here's the list that come with the current version of their distribution.
You also get access to conda, which is a package and environment manager. Think pip + virtualenv.
Once you have that, you can do
conda create -n my_env python=3.6 numpy pandas
This will install Python 3.6 and all of the dependencies for numpy and pandas into a virtual environment called my_env. Conda will make sure that you have the most up to date packages that work together.
To access your environment, you can do:
activate my_env
Now you're running Python in that environment with those installed packages. If you need more packages, you can either do conda install package_name. If conda can't find the package, you can still do pip install package_name.
Note that as an added bonus, you get an optimized and pre-compiled version of Numpy by way of the Intel MKL.
(From my comment on a previous answer)
I'd second the recommendation for going the Anaconda route.
Particularly if you're using Numpy or anything that depends on Numpy
(Pandas, Scipy, Sci-kit Learn). Continuum has access to the Intel MKL
which gives you significant optimizations and pre-compiled C code
specific to your operating system. docs.continuum.io/mkl-optimizations
What I did to try and solve this issue:
Using Mac OS X
Using Anaconda distro currently in my computer as the path /Users/hongshuhong/anaconda/
Used conda instead of virtualenv because of my distribution of python. I referred to the guide here and tried to download the same with conda's package manager: https://www.tensorflow.org/versions/master/get_started/os_setup.html#download-and-setup
Tensorflow worked correctly when I created an anaconda env using the command conda create --name ML python=2.7 anaconda to state I'm using 2.7 python, then used this command conda install -c https://conda.anaconda.org/jjhelmus tensorflow
gathered from the Anaconda Cloud to attempt to download it. It worked when I said
$ python
>>> import tensorflow as tf
...
However, it doesn't really fix the issue:
However, I want to use the 3.5 distribution of python, simply to keep up with the times and not use outdated pythons.
I attempted to download it using the same way in python=3.5, but it raised this error when I tried to run the command conda install -c https://conda.anaconda.org/jjhelmus tensorflow :
Hint: the following packages conflict with each other:
- tensorflow
- python 3.5*
Use 'conda info tensorflow' etc. to see the dependencies for each package.
And I ran the conda info tensorflow to see what was going on and I got:
Fetching package metadata: ....
Error: No packages found in current osx-64 channels matching: tensorflow
This is really frustrating me and I'm not sure what to do. If there's no work around for this, I think I'll have to use Anaconda's python 2.7 distribution for TensorFlow experiments. If anyone has any idea how to solve this compatibility issue(or some other kind of issue), I'd be extremely grateful. Thanks.
EDIT: I'm pretty sure TensorFlow supports 3.5 because in their documentations they say they support 2.7 python and 3.3+. If there were no clues as to whether they support 3.5, I would have already given up and used 2.7 by now.
The version of TensorFlow packaged here is version 0.5.
Python 3.x support was introduced in TensorFlow 0.6, so you need to figure out how to install the newest version into Anaconda.
Usually you can install packages into anaconda using pip, but I haven't succeeded with TensorFlow.
EDIT: I just noticed that the documentation hasn't updated the url to the pip-wheel.
To install tensorflow in python 3.5 via pip, use the following command:
$ sudo easy_install --upgrade six
$ sudo pip install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.6.0-py3-none-any.whl
This links to ...tensorflow-0.5.0-py2-none-any.whl, which is an older version of tensorflow for python 2.x.
Tensorflow get started page link.
To be more precise, I need to install two versions of Pandas. On one hand, I'm writing codes to be run on a server with pandas 0.13. All other part of my work, I want up-to-date pandas and other modules (0.16.1 for now).
The two projects are not connected and I won't need two versions in one program.
Is there a way to do that?
Edit: I'm using Python 2.7.8 with Anaconda under Windows
The best method is virtualenv. Virtualenv is a tool to create isolated Python environments.
http://virtualenv.readthedocs.org/en/latest/
I would highly recommended miniconda, which is the smaller version of Anaconda. Conda is a package manager which makes installing scientific libraries such as Scipy and Numpy easy. To get it, just install the Miniconda installer.
“Miniconda” only contains Python and conda, and is much smaller than
a full Anaconda installer. There are two variants of the installer:
Miniconda is based on Python 2, while Miniconda3 is based on Python 3.
Once Miniconda is installed, you can use the conda command to install
any other packages and create environments (still containing any
version of Python you want). If you have a slow internet connection or
limited disk space, Miniconda is the way to go.
It is fast to install packagaes such as Pandas and Numpy because many have been precompiled.
On OS X, the latest Python 2 version can be found here and is installed as follows:
$ bashMiniconda-latest-MacOSX-x86_64.sh -p /usr/local/miniconda -b
$ export PATH=/usr/local/miniconda/bin:$PATH
$ which conda
/usr/local/miniconda/bin/conda
$ conda --version
conda 3.7.0
Once Miniconda is installed, you can use the conda command to install any other packages and versions, and create environments, etc. For example:
$ conda install pandas=0.16.0
...
$ conda create -n py3k anaconda python=3
...
Two versions of the same package cannot run simultaneously, so I would recommend setting up a copy of your existing environment and then installing the desired version.
conda list will show all of your installed packages.
Use pkg_resourcesto force the version:
import pkg_resources
pkg_resources.require("YOUR_PACKAGE==VERSION")
import YOUR_PACKAGE