Ich habe gerade den neuesten Tensorflow auf Ubuntu neu installiert:
$ Sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.7.1-cp27-none-linux_x86_64.whl
[Sudo] password for ubuntu:
The directory '/home/ubuntu/.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/ubuntu/.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 tensorflow==0.7.1 from https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.7.1-cp27-none-linux_x86_64.whl
Downloading https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.7.1-cp27-none-linux_x86_64.whl (13.8MB)
100% |████████████████████████████████| 13.8MB 32kB/s
Requirement already up-to-date: six>=1.10.0 in /usr/local/lib/python2.7/dist-packages (from tensorflow==0.7.1)
Requirement already up-to-date: protobuf==3.0.0b2 in /usr/local/lib/python2.7/dist-packages (from tensorflow==0.7.1)
Requirement already up-to-date: wheel in /usr/local/lib/python2.7/dist-packages (from tensorflow==0.7.1)
Requirement already up-to-date: numpy>=1.8.2 in /usr/local/lib/python2.7/dist-packages (from tensorflow==0.7.1)
Requirement already up-to-date: setuptools in /usr/local/lib/python2.7/dist-packages (from protobuf==3.0.0b2->tensorflow==0.7.1)
Installing collected packages: tensorflow
Found existing installation: tensorflow 0.7.1
Uninstalling tensorflow-0.7.1:
Successfully uninstalled tensorflow-0.7.1
Successfully installed tensorflow-0.7.1
Wenn Sie den Anweisungen zum Testen folgen, schlägt der Befehl fehl: Name pywrap_tensorflow kann nicht importiert werden:
$ ipython
/git/tensorflow/tensorflow/__init__.py in <module>()
21 from __future__ import print_function
22
---> 23 from tensorflow.python import *
/git/tensorflow/tensorflow/python/__init__.py in <module>()
43 _default_dlopen_flags = sys.getdlopenflags()
44 sys.setdlopenflags(_default_dlopen_flags | ctypes.RTLD_GLOBAL)
---> 45 from tensorflow.python import pywrap_tensorflow
46 sys.setdlopenflags(_default_dlopen_flags)
47
ImportError: cannot import name pywrap_tensorflow
Gibt es eine zusätzliche Änderung an meiner Python- oder Ubuntu/Bash-Umgebung?
Aus dem Pfad in Ihrer Stack-Ablaufverfolgung (/git/tensorflow/tensorflow/…
) sieht es so aus, als würde Ihr Python-Pfad die Tensorflow-Bibliotheken aus dem Quellverzeichnis und nicht aus der installierten Version laden. Daher kann die (kompilierte) pywrap_tensorflow
-Bibliothek nicht gefunden werden, die in einem anderen Verzeichnis installiert ist.
Eine gängige Lösung ist, cd
aus dem /git/tensorflow
-Verzeichnis zu entfernen, bevor Sie python
oder ipython
starten.
Befehl unten hat mir geholfen.
pip install tensorflow --upgrade --force-reinstall
Ich habe TensorFlow aus dem Quellcode (GitHub: https://github.com/tensorflow/tensorflow ) in einer virtuellen Umgebung von Python 2.7 (venv) kompiliert und installiert. Es funktionierte gut, aber ich musste (wie andere bereits erwähnt haben, zB Benutzer "mrry" bei Fehler beim Ausführen des grundlegenden Tensorflow-Beispiels ), um aus der Partition, in der ich TensorFlow kompiliert hatte, eine andere Partition zu erstellen Tensorflow in Python importieren können. Ansonsten bekam ich verschiedene Fehler, abhängig davon, in welchem Verzeichnis (Quellpartition) ich war. Um zu klären:
source: /mnt/Vancouver/apps/tensorflow
can't import tf: Python launched in any of /mnt/...
can import tf: Python launched in /home/victoria/...
Ich habe später nur die Anweisungen hier befolgt,
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md#anaconda-installation
und alles funktioniert einfach gut.
Als Referenz arbeite ich weiter
INSTALLIEREN SIE SCHRITTE:
Ändern Sie Pfade und Venv-Namen nach Ihren Wünschen.
Tf-env erstellen:
cd /home/victoria/anaconda3/envs
conda create -n tf-env python=2.7 anaconda
Hinweis: Durch das Anhängen des Metapakets "Anaconda" werden ALLE Anaconda-Pakete (NumPy; ...) installiert.
Quelle aktiviere das venv (tf-env)
source activate tf-env
Anmerkung: Als Alias zu ~/.bashrc hinzugefügt:
alias tf='echo " [TensorFlow in Anaconda Python 2.7 venv (source activate tf]" && source activate tf-env'
Installieren Sie TensorFlow im tf-env-Fenster:
(tf-env)$ conda install -c conda-forge tensorflow
DIESES vermeidet die Verwendung von pip (einschließlich des * .whl-Installationsskripts), einer alternativen Methode zur Installation von TensorFlow, die hier beschrieben wird:
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md).
FUNKTIONIERT!
(tf-env)[[email protected] ~]$ P
[P: python]
Python 2.7.12 |Anaconda 4.1.1 (64-bit)| (default, Jul 2 2016, 17:42:40)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
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
>>> print tensorflow.__version__
0.9.0
>>> [Ctrl-D]
(tf-env)[[email protected] ~]$
Sie können dann mit TensorFlow im tf-env arbeiten. B. in Jupyter-Notebooks, die in dieser (tf-env) -Version eingeführt wurden.
In meinem python -m venv environment
schien es behoben zu sein durch:
pip uninstall tensorflow
Ändern Sie requirements.txt
in tensorflow==1.5.0
anstelle von tensorflow==1.8.0
.
pip install -r requirements.txt
Ich verwende Tensorflow 1.13.1. Nur die Neuinstallation von Tensorflow hat bei mir funktioniert.
Die Installation über den folgenden Befehl löst das Problem:
pip install --upgrade
Hier ist der Link zum Download
Ich habe auch dieses Problem und habe es für eine lange Zeit untersucht. Es scheint, dass es auf python 3+ kein solches Problem gibt. Auf py2.7 - Das Problem ist eigentlich auf google.protobuf
pip uninstall protobuf
pip uninstall google
pip install google
pip install protobuf
pip install google-cloud
Erstelle einen __init__.py
im "google" Ordner.
cd /path/to/your/env/lib/python2.7/site-packages/google
touch __init__.py
Hoffentlich klappt es.
wenn Sie eine vor 2011 hergestellte CPU verwenden, haben Sie die tensorflow-Version von 1.8.0 auf 1.5.0 oder 1.2.0 herabgestuft und versuchen, das Modul zu importieren, das für mich funktioniert hat.
Ich habe herausgefunden, dass TensorFlow 1.12.0 nur mit Python Version 3.5.2 funktioniert. Ich hatte Python 3.7, aber das hat nicht funktioniert. Also musste ich Python downgraden und dann konnte ich TensorFlow installieren, es funktioniert.
Zum Downgrade Ihrer Python-Version von 3.7 auf 3.6
conda install python=3.6.8