Installing prettytensor for TensorFlow not working on OSX - python

I can't install prettytensor. I've tried doing it through pip and also by installing the sourcecode and doing python setup.py install in the directory.
I updated my tensorflow . Does anyone have any idea on how I can install prettytensor on my machine?
pip install prettytensor
Requirement already satisfied (use --upgrade to upgrade): prettytensor in ./anaconda/lib/python2.7/site-packages/prettytensor-0.6.0-py2.7.egg
Requirement already satisfied (use --upgrade to upgrade): enum34>=1.0.0 in ./anaconda/lib/python2.7/site-packages (from prettytensor)
Requirement already satisfied (use --upgrade to upgrade): six>=1.10.0 in ./anaconda/lib/python2.7/site-packages (from prettytensor)
Collecting tensorflow>=0.7.1 (from prettytensor)
Could not find a version that satisfies the requirement tensorflow>=0.7.1 (from prettytensor) (from versions: )
No matching distribution found for tensorflow>=0.7.1 (from prettytensor)
when i try to import prettytensor
Python 2.7.11 |Anaconda 2.3.0 (x86_64)| (default, Dec 6 2015, 18:57:58)
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import tensorflow as tf
>>> import prettytensor as pt
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/Mu/anaconda/lib/python2.7/site-packages/prettytensor-0.6.0-py2.7.egg/prettytensor/__init__.py", line 25, in <module>
from prettytensor import funcs
File "/Users/Mu/anaconda/lib/python2.7/site-packages/prettytensor-0.6.0-py2.7.egg/prettytensor/funcs.py", line 25, in <module>
from prettytensor.pretty_tensor_image_methods import *
File "/Users/Mu/anaconda/lib/python2.7/site-packages/prettytensor-0.6.0-py2.7.egg/prettytensor/pretty_tensor_image_methods.py", line 20, in <module>
from prettytensor import layers
ImportError: cannot import name layers

Please check a version of tensorflow.
If your tensorflow is not 0.7.1, you can upgrade like below.
(see also https://www.tensorflow.org/versions/r0.7/get_started/os_setup.html)
# Mac OSX, CPU only:
$ pip install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.7.1-cp27-none-any.whl
Then install prettytensor again.
$ pip uninstall prettytensor
$ pip install prettytensor
For your reference.
Here is my results.(OSX 10.11.3)
In [1]: import tensorflow as tf
In [2]: tf.__version__
Out[2]: '0.7.1'
In [3]: import prettytensor as pt
In [4]: pt.PrettyTensor
Out[4]: prettytensor.pretty_tensor_class.PrettyTensor

Related

no module named Pillow

On Windows 10 pro, I am running a docker image with python and jupyter installed. I can start the docker image and from that shell start the jupyter notebook fine. Both python2 and python3 kernels are available. PIL and Pillow are installed but I cannot import them. See below:
(I have indicated the contents of each jupyter cell with double asterisks.
The result of each cell then simply follows below it)
**!pip install Image**
Requirement already satisfied: Image in /usr/local/lib/python3.6/dist-packages (1.5.27)
Requirement already satisfied: pillow in /usr/lib/python3/dist-packages (from Image) (5.1.0)
Requirement already satisfied: django in /usr/local/lib/python3.6/dist-packages (from Image) (2.2)
Requirement already satisfied: sqlparse in /usr/local/lib/python3.6/dist-packages (from django->Image) (0.3.0)
Requirement already satisfied: pytz in /usr/lib/python3/dist-packages (from django->Image) (2018.3)
You are using pip version 19.0.3, however version 19.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
**!pip install Pillow**
Requirement already satisfied: Pillow in /usr/lib/python3/dist-packages (5.1.0)
You are using pip version 19.0.3, however version 19.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
**!python -m pip install pillow**
Requirement already satisfied: pillow in /usr/lib/python3/dist-packages (5.1.0)
You are using pip version 19.0.3, however version 19.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
**import PIL**
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-7-70d569469e06> in <module>()
----> 1 import PIL
ImportError: No module named PIL
**import PIL.Image**
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-8-df3f6661ddbf> in <module>()
----> 1 import PIL.Image
ImportError: No module named PIL.Image
**import pillow**
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-11-e32915389b2c> in <module>()
----> 1 import pillow
ImportError: No module named pillow
But when I exit the notebook and start an interactive python session in the running docker container, PIL is found easily:
root#7092fc2336d3:/# python
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import PIL
>>>
well this is weird. It turns out that the pip in jupyter was installing in the python3 site packages but the python in the jupyter notebook was looking in the python2 site packages. so when I installed pillow in a jupyter cell like so
!/usr/bin/python2.7 -m pip install Pillow
now this works
import PIL.Image

python 2.7 bcrypt not found after pip already satisfied

me#localhost:# sudo pip install bcrypt
Requirement already satisfied (use --upgrade to upgrade): bcrypt in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied (use --upgrade to upgrade): cffi>=1.1 in /usr/local/lib/python2.7/dist-packages (from bcrypt)
Requirement already satisfied (use --upgrade to upgrade): six>=1.4.1 in /usr/lib/python2.7/dist-packages (from bcrypt)
Requirement already satisfied (use --upgrade to upgrade): pycparser in /usr/local/lib/python2.7/dist-packages (from cffi>=1.1->bcrypt)
Cleaning up...
me#localhost:# python
Python 2.7.12 (default, Mar 19 2017, 23:18:21)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import bcrypt
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named bcrypt
Why does pip say bcrypt is there when it obviously isn't? Lies!
Python 3 doesn't have access to it either.
me#localhost:# python3
Python 3.4.3 (default, Nov 17 2016, 01:08:31)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import bcrypt
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'bcrypt'
So I guess pip is just unreliable?
The command is now pip install python-bcrypt after looking at the README.md here (in the tar.gz after extracting).
It would be nice if someone updated these docs.

Keras can't be imported in Virtual Env

Any idea how this could be fixed?
mona#pascal:~$ python3
Python 3.4.3 (default, Nov 17 2016, 01:08:31)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import keras
Using TensorFlow backend.
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcublas.so locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcudnn.so locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcufft.so locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcurand.so locally
mona#pascal:~$ source /usr/local/bin/virtualenvwrapper.sh
mona#pascal:~$ workon cv2
(cv2) mona#pascal:~$ python
Python 3.4.3 (default, Nov 17 2016, 01:08:31)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import keras
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'keras'
UPDATE:
$ sudo pip install keras
The directory '/home/mona/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/mona/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting keras
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning.
SNIMissingWarning
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Downloading Keras-1.2.0.tar.gz (167kB)
100% |████████████████████████████████| 174kB 2.1MB/s
Collecting theano (from keras)
Downloading Theano-0.8.2.tar.gz (2.9MB)
100% |████████████████████████████████| 2.9MB 346kB/s
Requirement already satisfied: pyyaml in /usr/lib/python2.7/dist-packages (from keras)
Requirement already satisfied: six in /usr/local/lib/python2.7/dist-packages (from keras)
Requirement already satisfied: numpy>=1.7.1 in /usr/local/lib/python2.7/dist-packages (from theano->keras)
Requirement already satisfied: scipy>=0.11 in /usr/lib/python2.7/dist-packages (from theano->keras)
Installing collected packages: theano, keras
Running setup.py install for theano ... done
Running setup.py install for keras ... done
Successfully installed keras-1.2.0 theano-0.8.2
(cv2) mona#pascal:~/computer_vision/opencv-3.2.0/build$ python
Python 3.4.3 (default, Nov 17 2016, 01:08:31)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import keras
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'keras'
(cv2) mona#pascal:~/computer_vision/opencv-3.2.0/build$ sudo pip3 install keras
Requirement already satisfied (use --upgrade to upgrade): keras in /usr/local/lib/python3.4/dist-packages
Requirement already satisfied (use --upgrade to upgrade): theano in /usr/local/lib/python3.4/dist-packages (from keras)
Requirement already satisfied (use --upgrade to upgrade): pyyaml in /usr/local/lib/python3.4/dist-packages (from keras)
Requirement already satisfied (use --upgrade to upgrade): six in /usr/local/lib/python3.4/dist-packages (from keras)
Requirement already satisfied (use --upgrade to upgrade): numpy>=1.7.1 in /usr/local/lib/python3.4/dist-packages (from theano->keras)
Requirement already satisfied (use --upgrade to upgrade): scipy>=0.11 in /usr/local/lib/python3.4/dist-packages (from theano->keras)
Cleaning up...
(cv2) mona#pascal:~/computer_vision/opencv-3.2.0/build$ sudo pip3 install --upgrade keras
Requirement already up-to-date: keras in /usr/local/lib/python3.4/dist-packages
Requirement already up-to-date: theano in /usr/local/lib/python3.4/dist-packages (from keras)
Requirement already up-to-date: pyyaml in /usr/local/lib/python3.4/dist-packages (from keras)
Requirement already up-to-date: six in /usr/local/lib/python3.4/dist-packages (from keras)
Requirement already up-to-date: numpy>=1.7.1 in /usr/local/lib/python3.4/dist-packages (from theano->keras)
Requirement already up-to-date: scipy>=0.11 in /usr/local/lib/python3.4/dist-packages (from theano->keras)
Cleaning up...
(cv2) mona#pascal:~/computer_vision/opencv-3.2.0/build$ python
Python 3.4.3 (default, Nov 17 2016, 01:08:31)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import keras
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'keras'
The problem is that you are running pip with sudo from the virtualenv. This temporarily makes you root, resets all the environment variables that are set by virtualenvwrapper and thus installs the packages system-wide instead in the virtualenv.
This should work better:
workon cv2
pip install keras tensorflow
Is it possible when creating cv2 environment, you did not create it with --system-site-packages flag?
If not, you can always pip install keras inside the virtualenv.

Cannot import pandas after pip install pandas

I run the following command to install pandas via pip:
sudo pip install pandas --upgrade
which outputs
Requirement already up-to-date: pandas in /opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages
Requirement already up-to-date: numpy>=1.7.0 in /opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages (from pandas)
Requirement already up-to-date: python-dateutil>=2 in /opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages (from pandas)
Requirement already up-to-date: pytz>=2011k in /opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages (from pandas)
Requirement already up-to-date: six>=1.5 in /opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages (from python-dateutil>=2->pandas)
However, when I use python3 in the command line, I cannot import pandas:
$ python3
>>> import pandas
>>> Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'pandas'
It appears that this is in the correct location, as
which python3
is in the following location:
/opt/local/bin/python3
Executing within python3
>>> import sys
>>> print(sys.version)
outputs
'3.4.5 (default, Jun 27 2016, 04:57:21) \n[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)]'
Why can't I import pandas?
EDIT: I'm using pip version pip3:
pip --version
outputs
pip 8.1.2 from /opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages (python 3.4)
Looks like your OS uses pip2 by default. This could be checked by typing:
$ pip --version
pip 8.1.2 from /usr/local/lib/python2.7/dist-packages (python 2.7)
Try to use pip3 command like that:
sudo pip3 install pandas --upgrade

really simple pip python-twitter issue; can't import twitter

I don't know what I'm doing wrong here:
Sun Oct 14$ pip install python-twitter
Requirement already satisfied (use --upgrade to upgrade): python-twitter in /Library/Python/2.7/site-packages
Requirement already satisfied (use --upgrade to upgrade): setuptools in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from python-twitter)
Requirement already satisfied (use --upgrade to upgrade): simplejson in /Library/Python/2.7/site-packages (from python-twitter)
Requirement already satisfied (use --upgrade to upgrade): oauth2 in /Library/Python/2.7/site-packages (from python-twitter)
Requirement already satisfied (use --upgrade to upgrade): httplib2 in /Library/Python/2.7/site-packages (from oauth2->python-twitter)
Cleaning up...
Sun Oct 14$ python
Python 2.7.2 (default, Nov 17 2011, 13:22:48)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import twitter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named twitter
>>>
Do I need to do a virtualenv? What else could be going on? Sorry for my lack of understanding but any help is appreciated.
edit #1
trying to get tweepy working but.... possibly might have two versions of Python 2.7 here
Sun Oct 14$ pip install --upgrade tweepy
Requirement already up-to-date: tweepy in ./tweepy-1.11-py2.7.egg
Cleaning up...
Sun Oct 14$ python
Python 2.7.2 (default, Nov 17 2011, 13:22:48)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tweepy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named tweepy
>>>
I think I might have two versions of Python 2.7 installed; one via homebrew and the Apple default. Is it possible that the homebrew install would put packages in /Library/Python/2.7/site-packages?
again, thx in advance
From what I've read, python-twitter:
Relies on Basic-Auth which Twitter switched off sometime between
August and September (2010). Only OAuth is supported by the API, and
python-twitter doesn't support this.
UPDATE: I just tried installing python-twitter using the exact same method you used and I am unable to import it as well. After doing some research I came across Python Twitter Tools, which I believe is python-twitter's replacement.
Installing twitter requires setuptools. It's just easy_install twitter to install it from the web.

Categories