Installing tensorflow on virtualbox ubuntu 20.04 python 2.7 - 'Illegal instruction (core dumped)' - python-2.7

my goal is to follow this guide so that I can convert a Caffe model to a Tensorflow model. As my original OS is Windows 10 I am using the virtual Ubuntu 20.04 (using Oracle VirtualBox) with python 2.7 and anaconda virtual env. I am able to successfully install tensorflow for python 2.7, but when I run the command python -c 'import tensorflow', I get an error with text Illegal instruction (core dumped). I have tried to google to get more information but all I got was that it maybe has something to do with the architecture, I found out that my architecture (on the virtual ubuntu) is x86_64. That is all I have found out and now I turned to SO to ask what I should do to be able to run tensorflow in the before described environment, many thanks beforehand.

For those wondering, the pip or conda installation did not work in my case, so I followed the instructions on this guide for linux, python 2.7 using the pip installation method with a tensorflow version of 0.10, which for my purposes is good enough.
Exact steps in case the link does not work in the future:
$ conda create -n tensorflow python=2.7
$ conda activate tensorflow
Your prompt should change to this: (tensorflow)$
(tensorflow)$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.10.0-cp27-none-linux_x86_64.whl
(tensorflow)$ pip install --ignore-installed --upgrade $TF_BINARY_URL
This is, as outlined, for python 2.7, but the guide contains info for newer versions as well. To check whether tensorflow installed correctly you can run this command $ python -c 'import tensorflow as tf; print(tf.__version__)' which should output 0.10.0.

Related

pypy2.7.1.1 fails using pyenv

I am trying to install python version pypy2.7.1.1 using the following
pyenv install pypy2.7-7.1.1
I get the following error:
Downloading pypy2.7-v7.1.1-osx64.tar.bz2...
-> https://downloads.python.org/pypy/pypy2.7-v7.1.1-osx64.tar.bz2
Installing pypy2.7-v7.1.1-osx64...
Installing pip from https://bootstrap.pypa.io/get-pip.py...
error: failed to install pip via get-pip.py
BUILD FAILED (OS X 11.2.3 using 0000000000)
Inspect or clean up the working tree at /var/folders/zt/q3p12vyx3l990yc32wmybqdr0000gs/T/python-build.20210428193745.1720
Results logged to /var/folders/zt/q3p12vyx3l990yc32wmybqdr0000gs/T/python-build.20210428193745.1720.log
Last 10 log lines:
/var/folders/zt/q3p12vyx3l990yc32wmybqdr0000gs/T/python-build.20210428193745.1720 ~
/var/folders/zt/q3p12vyx3l990yc32wmybqdr0000gs/T/python-build.20210428193745.1720/pypy2.7-v7.1.1-osx64 /var/folders/zt/q3p12vyx3l990yc32wmybqdr0000gs/T/python-build.20210428193745.1720 ~
ERROR: This script does not work on Python 2.7 The minimum supported Python version is 3.6. Please use https://bootstrap.pypa.io/pip/2.7/get-pip.py instead.
since pip was moved for 2.7 how do I install this now? is there a different way to install deprecated versions of python now?
I was having a similar issue on Mac OS 10.15.7 (Catalina).
This is how I was finally able to install Python 2.7 via pyenv
export GET_PIP_URL=https://bootstrap.pypa.io/pip/2.7/get-pip.py
PYTHON_BUILD_HOMEBREW_OPENSSL_FORMULA=openssl#1.0 pyenv install 2.7.5
I realize that you are trying to install pypy and not Python, but hopefully the method above helps you, or others!

Install opencv python package in Anaconda

Can someone provide the steps and the necessary links of the dependencies to install external python package "opencv-python" for image processing?
I tried installing it in pycharm, but it was not able to import cv2(opencv) and was throwing version mismatch with numpy!
Please help!
The good thing with anaconda is that it should make your life easier without getting your hands too dirty. If you use only basic libs, only install packages with anaconda commands to be sure not to corrupt your python environment.
if you're on linux, use conda install -c conda-forge opencv
on windows, do the same with the "anaconda prompt" terminal.
If you still have some trouble with you numpy version, try conda update numpy
Create a virtual env. Following which run following instals
pip install numpy scipy matplotlib scikit-learn jupyter
pip install opencv-contrib-python
pip install dlib
You may verify the install via this script in Python environment-
import cv2
cv2.version
Remove all previous/current (if any) python installation
Install Anaconda and add anaconda to PATH(Envirnoment variables:: Adavanced system setting->Environment variables->under system variables go to variable PATHand click edit to add new envirnomental variables)
(During installation check box involve PATH)
Open anaconda prompt with admin access. Type and enter:-
conda update --all
conda install -c conda-forge opencv
conda install spyder=4.0.0 (spyder updation)
conda update python (for python updation)
To install this package with conda run one of the following:
conda install -c conda-forge opencv
conda install -c conda-forge/label/gcc7 opencv
conda install -c conda-forge/label/broken opencv
conda install -c conda-forge/label/cf201901 opencv

Python import tensorflow in virtualenv creates segfault

I am using Ubuntu 14.04 and I installed tensorflow 0.8.0 (64 bits CPU only) in a virtualenv (using pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0-cp27-none-linux_x86_64.whl).
Running python -c "import tensorflow" gives the following error
Segmentation fault (core dumped)
However, running import tensorflow in a Spyder console (whose interpreter is the virtualenv's one) works fine.
I am sure that the interpreter used is the same in both cases (I have printed sys.executable)
Any idea of what's happening here?
Edit: Installing tf outside the virtualenv, I can execute import tensorflow without any issue.
Another version of Tensorflow was installed outside of the virtualenv; I uninstalled it and reinstalled tf in the virtualenv. Now everything works fine.

How do I install Keras and Theano in Anaconda Python on Windows?

I am trying to work on neural networks in Python using the following Keras packages:
from keras.utils import np_utils
from keras.layers.core import Dense, Activation, Dropout
from keras.models import Sequential
from keras.layers.core import Dense, Dropout, Activation, Flatten
from keras.layers.convolutional import Convolution2D, MaxPooling2D
from keras.optimizers import SGD
But, I am getting the following error:
15 import theano
---> 16 from theano import gof
17 from theano.compat.python2x import partial
18 import theano.compile.mode
ImportError: cannot import name gof
Installing installed conda install keras. Later I tried to use pip install Theano, but it did not work. I Tried to install using pip install git, but I am getting this error: cannot find command git. So I installed Git and I set the environment variables.
So, is there any procedure to install these packages?
It is my solution for the same problem
Install TDM GCC x64.
Install Anaconda x64.
Open the Anaconda prompt
Run conda update conda
Run conda update --all
Run conda install mingw libpython
Install the latest version of Theano,
pip install git+git://github.com/Theano/Theano.git
Run pip install git+git://github.com/fchollet/keras.git
The trick is that you need to create an environment/workspace for Python. This solution should work for Python 2.7 but at the time of writing keras can run on python 3.5, especially if you have the latest anaconda installed (this took me awhile to figure out so I'll outline the steps I took to install KERAS in python 3.5):
Create environment/workspace for Python 3.5
C:\conda create --name neuralnets python=3.5
C:\activate neuralnets
Install everything (notice the neuralnets workspace in parenthesis on each line). Accept any dependencies each of those steps wants to install:
(neuralnets) C:\conda install theano
(neuralnets) C:\conda install mingw libpython
(neuralnets) C:\pip install tensorflow
(neuralnets) C:\pip install keras
Test it out:
(neuralnets) C:\python -c "from keras import backend; print(backend._BACKEND)"
Just remember, if you want to work in the workspace you always have to do:
C:\activate neuralnets
so you can launch Jupyter for example (assuming you also have Jupyter installed in this environment/workspace) as:
C:\activate neuralnets
(neuralnets) jupyter notebook
You can read more about managing and creating conda environments/workspaces
at the follwing URL: https://conda.io/docs/using/envs.html
In windows with anaconda, just go on conda prompt and use this command
conda install --channel https://conda.anaconda.org/conda-forge keras
I use macOS and used to have the same problem.
Running the following command in the terminal saved me:
conda install -c conda-forge keras tensorflow
Hope it helps.
In case you want to train CNN's with the theano backend like the Keras mnist_cnn.py example:
You better use theano bleeding edge version. Otherwise there may occur assertion errors.
Run Theano bleeding edge
pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git
Run Keras (like 1.0.8 works fine)
pip install git+git://github.com/fchollet/keras.git
install by this command given below
conda install -c conda-forge keras
this is error "CondaError: Cannot link a source that does not exist" ive get in win 10.
for your error put this command in your command line.
conda update conda
this work for me .
In windows environment with Anconda. Go to anconda prompt from start. Then if you are behind proxy then .copndarc file needs to eb updated with the proxy details.
ssl_verify: false
channels:
- defaults
proxy_servers:
http: http://xx.xx.xx.xx:xxxx
https: https://xx.xx.xx.xx:xxxx
I had ssl_verify initially marked as 'True' then I was getting ssl error. So i turned it to false as above and then ran the below commands
conda update conda
conda update --all
conda install --channel https://conda.anaconda.org/conda-forge keras
conda install --channel https://conda.anaconda.org/conda-forge tensorflow
My python version is 3.6.7
Anaconda with Windows
Run anaconda prompt with administrator privilages
conda update conda
conda update --all
conda install mingw libpython
conda install theano
After conda commands it's required to accept process - Proceed ([y]/n)?

How does Python work on Cygwin?

I installed Python 2.7.9 from (https://www.python.org/downloads/windows/), and then Cygwin 2.8.59. But I had problems when installing numpy.
pip install numpy
error: Unable to find vcvarsall.bat
So I uninstalled python using set-x86.exe (Cygwin installer). Now my commands python and pip are these:
$ which python
/cygdrive/c/Python27/python
$ which pip
/cygdrive/c/Python27/Scripts/pip
I could installed numpy using pip, and execute files by "python test.py". I, however, cannot use interactive console. If I type
$python
the console freezes and I cannot do anything other than Ctrl+C.
How should I do to use the command, "python"?
Try
cygstart /cygdrive/c/Python27/python.exe
According to this question: Using Windows Python from Cygwin
cygwin is just going to hang because windows doesn't think that the cygwin command 'Python' means interactive console, and will not flush the buffer as if it were an interactive console.