mxnet installation: How to choose python version? - mxnet

I installed mxnet in linux mint. I use anaconda for python 3.5. I followed the instruction and it was successfully installed. Both mxnet and the anaconda are latest version. However, when I tried the code:
import mxnet as mx
res = mx.nd.array([1,2,3])
I got the error:
AttributeError: module 'mxnet' has no attribute 'nd'
if I typed mx, I got: <module 'mxnet' (namespace)>
after repeating the installation and checking the scripts, I saw mxnet was installed under python 2.7, and graphviz is also under python 2.7. How can change them to python 3.5?

Working for MXNet python 3 is still in progress. Some functions are not fully tested yet.
At this time I suggest using python 2.7.

It should work in Python 3 environments.
I've installed MXNet in one easy set with pip3 in a python environment.
Everything works well.
Missing are some MXNet python API's advertised in the documentation, which are absent in the distribution and look absent in the current head of the repository as well.
So, I would not currently depend on the tutorial or example documentation -- they seem to be outdated or ahead of the repository. They cannot always guide you properly although in order to rescue yourself from particular situations reading the actual API documentation might help.

Anaconda Python 3.5 works fine for MXNet. See evidence below.
$ which python
/Users/username/anaconda3/bin/python
$ python --version
Python 3.5.2 :: Anaconda 4.2.0 (x86_64)
$ python
Python 3.5.2 |Anaconda 4.2.0 (x86_64)| (default, Jul 2 2016, 17:52:12)
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import mxnet as mx
>>> res = mx.nd.array([1,2,3])
>>> print(res)
<NDArray 3 #cpu(0)>
>>> print(res.asnumpy())
[ 1. 2. 3.]
>>> mx
<module 'mxnet' from '/Users/username/anaconda3/lib/python3.5/site-packages/mxnet-0.9.5-py3.5.egg/mxnet/__init__.py'>
The Python API documentation has been updated in newer releases. See: https://github.com/dmlc/mxnet/releases

When you use Anaconda3 with Python3 and MXNet, the installation process might get a bit cumbersome.
In my case, after following the installation steps and executing python setup.py install - I had to manually copy python/mxnet files into the ~/Anaconda3/Lib/site-packages/mxnet*../
Before I copied the files, I've seen the same error module 'mxnet' has no attribute 'nd'

Related

Installing tensorflow with pip results in errors

I'm trying to install TensorFlow with pip, but it shows me the following output:
pip install tensorflow
Defaulting to user installation because normal site-packages is not writeable
ERROR: Could not find a version that satisfies the requirement tensorflow
ERROR: No matching distribution found for tensorflow
I'm using Python 3.9.1 on Arch Linux.
Python 3.9 is not supported as far as I can tell: https://www.tensorflow.org/install/pip#system-requirements
You would need to use a supported version of the Python interpreter. The current supported interpreters seem to be: Python 3.5–3.8

Can't install tensorflow on python 3.9

When I try to install tensorflow on python 3.9 I get following error:
ERROR: Could not find a version that satisfies the requirement tensorflow (from versions: none)
ERROR: No matching distribution found for tensorflow
Is not there any tensorflow for 3.9?
What do you guys recommend?
Can I install other version of python beside the existing version?
Right now tensorflow does not have a build for python3.9
The latest one is for python3.8
You can check the build files at PyPI
https://pypi.org/project/tensorflow/#files
yes, you can install another version of python.
The original poster did not mention what type of computer or operating system he was using while attempting to install TensorFlow alongside Python 3.9. The error could be linked to working on a 64-bit Mac with the M1 chip (I recently experienced the same error described above while working on a Mac M1 in a Miniconda environment with Python 3.9.13). I solved the error by running
python3 -m pip install tensorflow-macos
from Terminal (in the Miniconda environment). TensorFlow installed normally alongside Python 3.9.13.
I do recommend installing Miniconda (or Anaconda as others have suggested), because it will allow you to easily create development environments with whatever version of Python modules or dependencies you require at the moment. See https://docs.conda.io/en/latest/miniconda.html. The larger Anaconda comes with a user-friendly 'Navigator' GUI which enables you to choose which environment is used to open a Jupyter notebook or other development environment, several of which come with Anaconda. See https://docs.anaconda.com/anaconda/install/
This is terrible with newer versions of Python that are not compatible with the machine learning module package.
So my approach is to keep the existing version 3.9 and the computer is using Anaconda to install a virtual environment with 3.7. When using vscode or pycharm, just remember to set it to that 3.7 Python environment.

Unable to install XGBOOST on MAC using Anaconda

I am using the Graphical Interface of Anaconda. I tried to install py-xgboost but it gave me the following error-
*UnsatisfiableError: The following specifications were found
to be incompatible with the existing python installation in your environment:
Specifications:
py-xgboost -> python[version='>=2.7,<2.8.0a0|>=3.6,<3.7.0a0|>=3.7,<3.8.0a0|>=3.5,<3.6.0a0']
Your python: python=3.8
If python is on the left-most side of the chain, that's the version you've asked for.
When python appears to the right, that indicates that the thing on the left is somehow
not available for the python version you are constrained to. Note that conda will not
change your python version to a different minor version unless you explicitly specify
that.*
It says I have python 3.8 installed in my system but when I checked the python version on my system using the command python2 --version & python3 --version it says I have python 2.7.16 & python 3.7.3
I dont have python 3.8
What shall I do now? The above python version were there already. I never installed and someone told me not to remove those versions as some of the MAC applications are dependent on them. Its a MAC BOOK PRO 15 ( 2019 )
After some research I found a solution. I had to downgrade my python version.
But as explained above when I tried to check the version of python I am using I was getting 2.7 & 3.7.3 but my ANACONDA gives an error that I have version 3.8
That was because Anaconda uses the python which is installed in a separate directory, it was not using the python installed at the PATH directory. So I had to downgrade python which the ANACONDA was using by using the command -
conda search python
BTW if your terminal says conda command not found, then you need to edit your PATH first.
Then it gives a list of python version, you can then see which version is right for your XGboost version and then use the command-
conda install python=3.7.7
or whatever version you wanted to use.
After the downgrade of python, anaconda will ask you to downgrade other libraries as well, so go ahead and do that too unless you are using some command which was not there in the older version.
Now install py-xgboost from ANACONDA Graphical interface or by using conda method
conda install -c anaconda py-xgboost

Can not make Tensorflow work with pypy3 and conda. Invalid ELF

I want to try tensorflow inside pypy. I tried a few days and no luck. Following is the detail.
I am using UBuntu 18.04.
I install conda.
I install pypy through conda, conda install -c conda-forge pypy3.6
I got No matching distribution found for tensorflow if I tried pypy3 -m pip install tensorflow
I got invalid ELF header when I run my python code if I tried pypy3 -m pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.14.0-py3-none-any.whl
I even try to install tensorflow I build but I got not a supported wheel on this platform. The Tensorflow I build can be installed in python3.6 just not in pypy3.
I think the problem is python version different but I don't know hwo to fix it. I notice the python version is slightly different between my python and pypy3.
I don't know how to make those two python 3.6.9 identical. Build pypy from source myself?
(pypy3) joseph#joseph-Ubuntu:~/scripts$ python
Python 3.6.9 |Anaconda, Inc.| (default, Jul 30 2019, 19:07:31)
[GCC 7.3.0] on linux
(pypy3) joseph#joseph-Ubuntu:~/scripts$ pypy3
Python 3.6.9 (5da45ced70e515f94686be0df47c59abd1348ebc, Oct 18 2019, 07:48:38)
[PyPy 7.2.0 with GCC 7.3.0] on linux
Or is there is other way to solve this problem?
Or Not to use conda?
Thanks
Joseph
You have to somehow get tensorflow compiled for PyPy, you cannot reuse one for CPython. So far there is no binary available, and I would not advise anyone to try to recompile tensorflow, it is quite hard. So I think for now sticking with CPython for tensorflow is the best course of action.

Jupyter notebook and QT Console are calling different version of pandas

QTConsole is running the latest version of pandas (i.e. 0.18). However, when I import pandas in Jupyter notebook, it can only import 0.15. How can I resolve this?
**QT Console:**
Jupyter QtConsole 4.2.0
Python 2.7.11 |Anaconda 4.0.0 (x86_64)| (default, Dec 6 2015, 18:57:58)
Type "copyright", "credits" or "license" for more information.
IPython 4.1.2 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
import pandas
print pandas.__version__
0.18.0
**Jupyter**
import pandas
print pandas.__version__
0.15.0
You probably have different versions of Python installed via different distributions. If you are using Windows, I recommend uninstalling all Python versions/distributions, rebooting and then only installing one.
If you are using Mac, ensure that you have only one version of Anaconda installed and that it is the version first in your PATH if you are using a terminal. It may be that a different version has been installed by for instance homebrew. To check your path do !echo $PATH from both of the environments. You should see your anaconda directory early in the path (before /usr/local/bin and /usr/bin). You can also do !which python from both of the environments to see which Python binary is being used.