简体   繁体   中英

ImportError: cannot import name 'compile'

I'm trying to install python 3.4 and TensorFlow on my Mac (OSX El Capitan version 10.11.1).
I am following the instructions here

Pip Installation

I can do

$ sudo easy_install pip
$ sudo easy_install --upgrade six  

but then this part gets difficult:

$ sudo pip install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.5.0-py2-none-any.whl  

I put in my password; it gives me a traceback:

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pkg_resources/__init__.py", line 2859, in _dep_map
return self.__dep_map
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pkg_resources/__init__.py", line 2696, in __getattr__
raise AttributeError(attr)
AttributeError: _DistInfoDistribution__dep_map

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.4/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pkg_resources/__init__.py", line 3138, in <module>
@_call_aside
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pkg_resources/__init__.py", line 3124, in _call_aside
f(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pkg_resources/__init__.py", line 3151, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pkg_resources/__init__.py", line 661, in _build_master
ws.require(__requires__)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pkg_resources/__init__.py", line 962, in require
needed = self.resolve(parse_requirements(requirements))
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pkg_resources/__init__.py", line 857, in resolve
new_requirements = dist.requires(req.extras)[::-1]
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pkg_resources/__init__.py", line 2640, in requires
dm = self._dep_map
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pkg_resources/__init__.py", line 2861, in _dep_map
self.__dep_map = self._compute_dependencies()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pkg_resources/__init__.py", line 2878, in _compute_dependencies
from _markerlib import compile as compile_marker
ImportError: cannot import name 'compile'

Did I miss any important information?

The main reason for this error is that the package you are trying to install is a Python 2 wheel file. (The py2 in the URL is the clue to this Moreover, as Guy Coder points out in the comments, you're installing version 0.5.0 of TensorFlow, which did not support Python 3.)

The best solution would be to install the Python 3–compatible package :

$ sudo pip install --upgrade http://storage.googleapis.com/tensorflow/mac/tensorflow-0.6.0-py3-none-any.whl

(It appears that these links aren't easy to find on the website, so we'll fix that shortly.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM