I am using tensorflow with python 2.7. However, after updating python 2.7.10 to 2.7.13, I get an import error with tensorflow
File "", line 1, in
File "/Users/usrname/Library/Python/2.7/lib/python/site-
packages/tensorflow/__init__.py", line 24, in
from tensorflow.python import *
File "/Users/usrname/Library/Python/2.7/lib/python/site-
packages/tensorflow/python/__init__.py", line 63, in
from tensorflow.core.framework.graph_pb2 import *
File "/Users/usrname/Library/Python/2.7/lib/python/site-
packages/tensorflow/core/framework/graph_pb2.py", line 6, in
from google.protobuf import descriptor as _descriptor
ImportError: No module named google.protobuf
Output from pip install protobuf
Requirement already satisfied: protobuf in /usr/local/lib/python2.7/site-packages
Requirement already satisfied: setuptools in /Users/usrname/Library/Python/2.7/lib/
python/site-packages (from protobuf)
Requirement already satisfied: six>=1.9 in /Library/Python/2.7/site-packages/
six-1.10.0-py2.7.egg (from protobuf)
Requirement already satisfied: appdirs>=1.4.0 in /usr/local/lib/python2.7/site-packages
(from setuptools->protobuf)
Requirement already satisfied: packaging>=16.8 in /usr/local/lib/python2.7/site-packages
(from setuptools->protobuf)
Requirement already satisfied: pyparsing in /usr/local/lib/python2.7/site-packages
(from packaging>=16.8->setuptools->protobuf)
Output from which python:
/Library/Frameworks/Python.framework/Versions/2.7/bin/python
I believe this path changed after the python update, but not sure. A solution could possibly be to downgrade python, but this seems like a bad solution? As I work in a team, I would like to avoid reinstalling Tensorflow due to end up with different versions, but this is perhaps the way to go? Any advice?
Update: I tired to install tensorflow all over, but the same error keeps popping up. Maybe the problem is the environment variables as which pipreturns /usr/local/bin/pip(which is different from which python)?
I had a similar problem. Make sure that pip and python has the same path when typing which pipand which python. If they differ, change your ~.bash_profile so that the python path match the pip path, and use source ~\.bash_profile.
If that doesn't work, I would try to reinstall pip and tensorflow.
I installed pip using this command:
wget https://bootstrap.pypa.io/get-pip.py
sudo python2.7 get-pip.py
Related
When I pip install the Image module for Python 3, the installation works fine. When I pip install the Image module for Python 2, the installation breaks:
Collecting pyprel
Downloading pyprel-2018.1.8.2203.tar.gz
Collecting Image (from pyprel)
Downloading image-1.5.17-py2.py3-none-any.whl
Collecting numpy (from pyprel)
Downloading numpy-1.14.0-cp27-cp27mu-manylinux1_x86_64.whl (16.9MB)
100% |████████████████████████████████| 16.9MB 79kB/s
Requirement already up-to-date: pyfiglet in /usr/local/lib/python2.7/dist-packages (from pyprel)
Requirement already up-to-date: shijian in /usr/local/lib/python2.7/dist-packages (from pyprel)
Collecting pillow (from Image->pyprel)
Downloading Pillow-5.0.0-cp27-cp27mu-manylinux1_x86_64.whl (5.8MB)
100% |████████████████████████████████| 5.9MB 230kB/s
Collecting django (from Image->pyprel)
Downloading Django-2.0.tar.gz (8.0MB)
100% |████████████████████████████████| 8.0MB 154kB/s
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-DZf02T/django/setup.py", line 32, in <module>
version = __import__('django').get_version()
File "django/__init__.py", line 1, in <module>
from django.utils.version import get_version
File "django/utils/version.py", line 61, in <module>
#functools.lru_cache()
AttributeError: 'module' object has no attribute 'lru_cache'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-DZf02T/django/
This may be because recent Django versions may no longer supporting Python 2, as suggested here. Is this actually the cause of the problem? I want to advise the relevant developers on what to do to fix the pip installation, perhaps by suggesting a Django version requirement, but I don't know how to do this. I would welcome guidance.
Assuming the Django requirement is set loosely, you can probably circumvent it by installing Django first, with a specific version that works for Python 2, and then install pyprel.
For example:
python2.7 -m pip install django==1.11
python2.7 -m pip install pyprel
The cause of the problem is the fact that pyprel uses an outdated import (and, apparently, outdated name) of the PIL package (essentially replaced by Pillow), Image. That results in pip installing an Image package, while it actually should install Pillow.
The import Image in pyprel should also be changed to from Pillow import Image to work with current Pillow versions.
(The deduction that this is actually the PIL/Pillow package comes from the fact that there is an Image.fromarray line, a function that I can't find image, but exists for PIL/Pillow).
There is no easy way out of this, other than filing an issue with the pyprel team, or downloading and altering the code yourself before installing. Because even with the above suggested installation, pyprel will likely run into problems at the import Image or Image.fromarray... line.
Note that this issue may also occur for Python 3. Installation may work, actually usage of pyprel may fail when encountering the above lines.
Django 2 does not support python2 at all. A major part of the release was removing all python2 compatibility.
As you can see in the docs, Django 2 requires 3.4, 3.5 or 3.6
Django Python
1.8 2.7, 3.2 (until the end of 2016), 3.3, 3.4, 3.5
1.9, 1.10 2.7, 3.4, 3.5
1.11 2.7, 3.4, 3.5, 3.6
2.0 3.4, 3.5, 3.6
2.1 3.5, 3.6, 3.7
I am attempting to install PyMC using pip install pymc. I believe this command should install PyMC 2.3.6.
PyMC has a few dependencies, which I have in my PATH. I am running OSX 10.11.2 and my PATH includes Python 2.7.13, NumPy 1.12.0, Matplotlib 2.0.0, gcc, and gfortran.
Python (including pip) was installed using Homebrew. NumPy and Matplotlib were installed using pip. The gfortran compiler was downloaded and installed from the GCC Wiki for the purpose of this installation.
Executing pip install pymc yielded lots of output including the following lines.
Collecting pymc
Using cached pymc-2.3.6.tar.gz
Complete output from command python setup.py egg_info:
running egg_info
running build_src
build_src
building extension "pymc.flib" sources
f2py options: ['skip:ppnd7']
f2py:> build/src.macosx-10.11-x86_64-2.7/pymc/flibmodule.c
creating build
creating build/src.macosx-10.11-x86_64-2.7
creating build/src.macosx-10.11-x86_64-2.7/pymc
IOError: [Errno 2] No such file or directory: 'skip:ppnd7'. Skipping file "skip:ppnd7".
updatevars:gradlike: attempt to change 'dimension(nx)' to 'dimension(na)'. Ignoring.
updatevars:gradlike: attempt to change 'dimension(nx)' to 'dimension(nb)'. Ignoring.
updatevars:gradlike: attempt to change 'dimension (nmu)' to 'dimension(nmu)'. Ignoring.
updatevars:gradlike: attempt to change 'dimension (na)' to 'dimension(na)'. Ignoring.
rmbadname1: Replacing "index" with "index_bn".
Reading fortran codes...
Reading file 'pymc/flib.f' (format:fix,strict)
Line #34 in pymc/flib.f:" PARAMETER (infinity = 1.7976931348623157d308)"
get_parameters: got "unexpected EOF while parsing (<string>, line 0)" on ''
...
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/2f/cr97n5v93mn04c3qbqd7r3q40000gn/T/pip-build-6Zmgcz/pymc/setup.py", line 124, in <module>
**(config_dict))
File "/usr/local/lib/python2.7/site-packages/numpy/distutils/core.py", line 169, in setup
return old_setup(**new_attr)
...
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/2f/cr97n5v93mn04c3qbqd7r3q40000gn/T/pip-build-6Zmgcz/pymc/
As suggested in these two pip installation threads about egg_info errors [1, 2], I ran pip install —upgrade setuptools and pip install ez_setup. Once these items were installed I ran into the same types of errors pasted above.
As noted in other package installation threads, I am willing to use conda to install PyMC if I cannot resolve these issues. However, I'd like to investigate this installation issue first.
Would anyone happen to know what my issue is here? Might there be some steps I can take to successfully install PyMC using pip?
I had the same problem. I don't understand the root cause, but I fixed it by downgrading numpy to version 1.10.1: pip install numpy==1.10.1
I also met this problem while trying to install pymc from pip or source code, but I found a solution that might be useful.
The reason that causes the problem might be the file setup.py, in which the script check the compile env. I didn't read the code very carefully, but in the function build_ext() I think the codes first check whether some compile environments have already been installed into OS. If installed, the script will use them as defaults; if not, use ones in somewhere else (the comment says 'from netlib sources').
I infer the problem is caused by the compile environments that have already been installed in the OS, so I modify the file setup.py to skip this part of codes, and let the script use the netlib source. Then I run sudo python setup.py install. There are some error and warning messages, but the folder 'pymc' emerges in python library, and some simple test codes run successfully.
In python 2.7.9 I was trying to install bottleneck without sudo access and use its one of the functions argpartsort. But this is what happens:
import bottleneck as bn
bn.argpartsort
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'argpartsort'
I tried various methods:
pip install --user bottleneck
Requirement already satisfied (use --upgrade to upgrade): bottleneck in $HOME/.local/lib/python2.7/site-packages/Bottleneck-1.3.0.dev0-py2.7-linux-x86_64.egg
Requirement already satisfied (use --upgrade to upgrade): numpy in $HOME/.local/lib/python2.7/site-packages (from bottleneck)
Cleaning up...
I tried building from source:
python setup.py install --user
Installed $HOME/.local/lib/python2.7/site-packages/Bottleneck-1.3.0.dev0-py2.7-linux-x86_64.egg
Processing dependencies for Bottleneck==1.3.0.dev0
Searching for numpy==1.12.0
Best match: numpy 1.12.0
Adding numpy 1.12.0 to easy-install.pth file
Using $HOME/.local/lib/python2.7/site-packages
Finished processing dependencies for Bottleneck==1.3.0.dev0
I then tried:
pip install --install-option="--prefix=$HOME/.local" bottleneck
Requirement already satisfied (use --upgrade to upgrade): bottleneck in $HOME/.local/lib/python2.7/site-packages/Bottleneck-1.3.0.dev0-py2.7-linux-x86_64.egg
Requirement already satisfied (use --upgrade to upgrade): numpy in $HOME/.local/lib/python2.7/site-packages (from bottleneck)
Cleaning up...
I tried to export environment variable:
export PYTHONPATH="$HOME/.local/lib/python2.7/site-packages"
but without any luck.
How can I use:
>>> import bottleneck as bn
>>> bn.argpartsort
and get around this error:
AttributeError: 'module' object has no attribute 'argpartsort'
without sudo permissions
I am on:
Distributor ID: Debian
Description: Debian GNU/Linux 8.6 (jessie)
Release: 8.6
Codename: jessie
I appreciate your help, however minimal.
Regards
There is likely nothing wrong with your install.
Check the Bottleneck 1.2.0 Release Notes:
Functions partsort and argpartsort have been renamed to partition and argpartition to match NumPy.
I tried looking for an answer to this around the forum/google, but I can't find anything. My issue is this (from python console):
>>> import pandas
cannot import name hashtable
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\pandas\__init__.py", line 6, in <module>
from . import hashtable, tslib, lib
ImportError: cannot import name hashtable //also can't import name NaT somtimes
I ran the windows 1-click installer prior to attempting the import. I'm running everything 32-bit. The pandas installer is for python 2.7.
Here's a list of modules that I have correctly imported into Python.
setuptools
pip
mox
dateutil
six
numpy
SQLAlchemy
I'm on windows 7.
I also have anaconda installed, but that was really just a "hail mary" after I tried everything else. My end goal is to install the ultra-finance module. However, it seems to require pandas, hence me being stuck.
I'm a python noob, so please don't assume I know anything. Thanks.
EDIT: please let me know if I can provide any extra information.
The recommended way to install pandas is via pip:
pip install pandas
This hashtables error arises from the cython files not being built. This error message will be more informative from 0.11.1.
Try running your code in Spyder (Anaconda -> Spyder). It worked for me.
Check that you have python scripts included in your system path variable. In my case I had to add "C:\Python27\Scripts"
I was having a similar problem when downloading Pandas to my Windows 8 system. The first error I had was an egg error, but after installing some packages I think I have the solution.
First look at the previous pip errors with Pandas, make sure you have the most updated pip.
The second part is downloading wheel using
pip install wheel
After installing wheel and having the dependencies for panda and using pip it worked correctly.
I'm trying to install http://pypi.python.org/pypi/django-crowdsourcing/1.1.21 using pip. I'm getting
$ pip install django-crowdsourcing==1.1.21
Downloading/unpacking django-crowdsourcing==1.1.21
Could not find a version that satisfies the requirement django-crowdsourcing==1.1.21 (from versions: )
No distributions matching the version for django-crowdsourcing==1.1.21
If I try an upgrade, it only finds version 1.1.19.
$ pip install -v --upgrade django-crowdsourcing
Downloading/unpacking django-crowdsourcing
Using version 1.1.19 (newest of versions: 1.1.19, 1.1.18, 1.1.17, 1.1.16, 1.1.15, 1.1.14, 1.1.13, 1.1.12, 1.1.11, 1.1.10, 1.1.9, 1.1.8, 1.1.7, 1.1.6)
Downloading django-crowdsourcing-1.1.19.tar.gz (651Kb): 651Kb downloaded
...
Successfully installed django-crowdsourcing
It looks like django-crowdsourcing version 1.1.21 has some good tags
$ hg tags
tip 289:8796aae85e34
1.1.21 288:2f39596495a7
1.1.20 281:fe00699aa3ff
1.1.19 278:17392ea8ea54
and the correct version number in setup.py
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
import os
readme_file = os.path.join(os.path.dirname(__file__),
'README')
long_description = open(readme_file).read()
classifiers = [
'Development Status :: 4 - Beta',
'Framework :: Django',
'License :: OSI Approved :: MIT License']
setup(name='django-crowdsourcing',
version='1.1.21',
classifiers=classifiers,
description='Django app for collecting and displaying surveys.',
long_description=long_description,
author='Jacob Smullyan, Dave Smith',
author_email='jsmullyan#gmail.com',
url='http://code.google.com/p/django-crowdsourcing/',
packages=['crowdsourcing', 'crowdsourcing.templatetags'],
license='MIT',
)
PyPi clearly knows about version 1.1.21 since that's what comes up when you go to http://pypi.python.org/pypi/django-crowdsourcing/ Why does pip think version 1.1.19 is the latest version?
Edit
Sheepishly, I forgot to point out I'm the maintainer. #Matthew Schinckel is right. Here are the two commands I needed, which I found out from a tutorial I didn't see before: http://wiki.python.org/moin/Distutils/Tutorial
$ python setup.py register
$ python setup.py sdist upload
There is no packaged file at version 1.1.21. There is one at 1.1.19. Tags in hg mean nothing to pip: it will only download a packaged up file.
Perhaps contact the maintainer, and point out there is no file release with the two most recent versions on pypi.