How to import global and virtual environment packages in Rodeo? - python-2.7

I have recently installed Tensorflow in a virtual environment and its working fine. I previously installed numpy,pandas,matplotlib and other packages as global packages(python 2.7). I want to use Tensorflow with other global packages using rodeo IDE.
I have successfully imported all packages this way using terminal
virtualenv env --system-site-packages
source /media/usr/dir/tensor/bin/activate
python -c "import tensorflow;print(tensorflow.__version__)"
0.10.0
python -c "import numpy;print(numpy.__version__)"
1.11.1
In rodeo I tried this way ten.sh
#!/bin/bash
virtualenv env --system-site-packages
source /media/usr/dir/tensor/bin/activate
Inside rodeo IDE
#rodeo
import os
os.system('/bin/bash --rcfile /media/usr/dir/tensor/ten.sh')
0
but when tried to import tensorflow its giving me error
ImportErrorTraceback (most recent call last) in ()
----> 1 import tensorflow
I also tried to change the path of the python (default to /media/usr/dir/tensor/bin/python) from IDE itself but after changing when I import any pacakges it return
>>> import tensorflow
This socket has been ended by the other party

Related

Jupyter No module named graphviz after successful installation

I installed graphviz by
conda install python-graphviz
after successful installation, when run
import graphviz
I got " ImportError: No module named graphviz" on jupyter notebook/python2.7.
But if run it in cmd like:
Python 2.7.15 |Anaconda, Inc |...
>>>import graphviz
>>>
it works well.
Why the "import graphviz" doesn't work in jupyter but work in cmd?
How to solve the problem?
You also need the Python interface for Graphviz
conda install -c conda-forge python-graphviz
Make sure that your jupyter notebook is using the same version of python as your terminal is seeing. So in jupyter notebook,
import sys
print(sys.version)
and do the same in python in your terminal. If they do not match, then load in the terminal version of python into your jupyter notebook:
conda install nb_conda_kernels
conda install ipykernel
and in the notebook, select it with kernel -> change kernel

ubuntu python anaconda2: cannot import matplotlib after activate tensorflow

Just as this question, I use Ubuntu and Anaconda for python 2.7 to install tensorflow and then activate the environment by source activate tensorflow which is exactly the same as shown in official website. After activation, use python command to enter python environment, now I can import tensorflow as tf but I cannot import matplotlib.
Without activating tensorflow, the import matplotlib works but in that case I cannot import tensorflow. So is it a conflict? Can someone tell me how to solve it? Is there any way to keep tensorflow always activated so that I don't need to activate it everytime (my previous ubuntu do have this feature but I forgot how did I make it)?
Try installing matplotlib using anaconda directly with conda install matplotlib from your tensorflow environment. One of the ideas of using anaconda is to keep environment self contained with the ability to avoid dependency conflicts (i.e. I don't see a point in activating the tensorflow for every new shell if you don't intend to use anaconda). You could either avoid the use of anaconda entirely and install tensorflow locally or export source activate tensorflow to your ~/.bashrc

import unicodecsv fails in jupyter

I tried to run
import unicodecsv
within jupyter by running a .ipynb file.
It failed.
Then I installed the unicodecsv file through the python install command and found it within c\python27 dir. But still the import did not happen.
How should it be installed. Does it need to be placed within the anaconda installation
Edit :
Error displayed -
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-9c1521d8df38> in <module>()
2 # 1 #
3 #####################################
----> 4 import unicodecsv
5 ## Read in the data from daily_engagement.csv and project_submissions.csv
6 ## and store the results in the below variables.
ImportError: No module named unicodecsv
Pip (Package Installer for Python) package manager also comes with Python3, you can try this variant without installing Conda (Windows):
python -m pip install unicodecsv
I had the same problem for the same file at Udacity.
Try changing the Kernel from Python2 to Python3 in the Kernel -> Change Kernel menu.
Hope that helps :)
You should install it (from the command prompt) using:
conda install unicodecsv
Install unicodecsv using:
sudo pip install unicodecsv
Restart/run your notebook again.
I had the same issue. Switching to Python 3 requires you to learn the new syntax and the rest of the nanodegree uses Python 2.
Make sure you are running the notebook in the same environment you are installing the the unicodecsv package in. Then:
conda install unicodecsv
should work. It did for me.

Pygame import error in pyenv 2.7.11 on Arch Linux

I installed pygame on my Arch Linux machine with the following command:
$ sudo pacman -S python2-pygame
I am using pyenv and the version of Python in my virtual environment for this project is 2.7.11
When I run my program
$ python smartcab/agent.py
here is what I get:
Traceback (most recent call last):
File "smartcab/agent.py", line 2, in <module>
from environment import Agent, Environment
File "/home/alex/machine-learning/projects/smartcab/smartcab/environment.py", line 5, in <module>
from simulator import Simulator
File "/home/alex/machine-learning/projects/smartcab/smartcab/simulator.py", line 4, in <module>
import pygame
ImportError: No module named pygame
How can I solve this please?
On my own Arch Linux machine...
I have created a 2.7.11 virtualenv using pyenv and installed python2-pygame with pacman. With my virtualenv activated, I couldn't import pygame from python. So I was able to reproduce your issue.
After that, I tried downloading and compiling pygame's source with python setup.py install without success. It is complaining about a missing linux/videodev.h which seems to be (from what I found on the web) deprecated and replaced by linux/videodev2.h (which is there).
I won't go further, I hope this will help someone finding the solution.

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)?