I installed Pycharm for Windows 10
pip install tensorflow went fine without errors
When trying to run a simple project
# Import `tensorflow`
import tensorflow as tf
# Initialize two constants
x1 = tf.constant([1,2,3,4])
x2 = tf.constant([5,6,7,8])
# Multiply
result = tf.multiply(x1, x2)
# Print the result
print(result)
I get the error message
Traceback (most recent call last):
File "C:/Users//PycharmProjects/RiffRam/RiffRam.py", line 2, in <module>
import tensorflow as tf
File "C:\Users\\PycharmProjects\RiffRam\venv\lib\site-packages\tensorflow\__init__.py", line 28, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "C:\Users\\PycharmProjects\RiffRam\venv\lib\site-packages\tensorflow\python\__init__.py", line 52, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "C:\Users\\PycharmProjects\RiffRam\venv\lib\site-packages\tensorflow\core\framework\graph_pb2.py", line 7, in <module>
from google.protobuf import descriptor as _descriptor
File "C:\Users\\PycharmProjects\RiffRam\venv\lib\site-packages\google\protobuf\descriptor.py", line 47, in <module>
from google.protobuf.pyext import _message
ImportError: DLL load failed: The specified procedure could not be found.
Can somebody please tell me how I can get a working installation of Tensorflow, it seems that all the versions are mismatched and pip makes no attempt to install correct versions of each package. I don't care if its outdated.
What commands do I need to type in to get a working stable version from a clean installation of Pycharm so that the code above would run?
Thank you
I got it
pip install --upgrade --force-reinstall setuptools==39.1.0
pip install --upgrade --force-reinstall protobuf==3.6.0
pip install --upgrade --force-reinstall tensorflow==1.11
Related
I successfully installed Spacy using pip install spacy and alternatively through Pycharms virtual env, but when I import spacy in my program it's giving me the following error;
home/pi/.virtualenvs/cv/bin/python /home/pi/PycharmProjects/testSpeech/main.py
Traceback (most recent call last):
File "/home/pi/PycharmProjects/testSpeech/main.py", line 2, in <module>
import spacy
File "/home/pi/.virtualenvs/cv/lib/python3.7/site-packages/spacy/__init__.py", line 10, in <module>
from thinc.neural.util import prefer_gpu, require_gpu
File "/home/pi/.virtualenvs/cv/lib/python3.7/site-packages/thinc/neural/__init__.py", line 4, in <module>
from ._classes.model import Model # noqa: F401
File "/home/pi/.virtualenvs/cv/lib/python3.7/site-packages/thinc/neural/_classes/model.py", line 11, in <module>
from ..train import Trainer
File "/home/pi/.virtualenvs/cv/lib/python3.7/site-packages/thinc/neural/train.py", line 7, in <module>
from .optimizers import Adam, linear_decay
File "thinc/neural/optimizers.pyx", line 14, in init thinc.neural.optimizers
File "thinc/neural/ops.pyx", line 36, in init thinc.neural.ops
File "/home/pi/.virtualenvs/cv/lib/python3.7/site-packages/blis/__init__.py", line 3, in <module>
from .cy import init
ImportError: /home/pi/.virtualenvs/cv/lib/python3.7/site-packages/blis/cy.cpython-37m-arm-linux-gnueabihf.so: undefined symbol: __atomic_load_8
Process finished with exit code 1
Any idea what's happening?
You probably have a 32-bit OS? Instead, you will need a 64-bit OS with 64-bit python for spaCy v2, e.g.: https://downloads.raspberrypi.org/raspios_arm64/images/raspios_arm64-2020-08-24/
As of spacy v2.3.5 you should be able to install spacy in a venv for linux aarch64 with:
python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip setuptools
pip install spacy
Alternatively, there are binary linux aarch64 packages on conda-forge. There's a linux aarch64 miniforge installer and the install command would be conda install spacy. If you're not using the miniforge installer, then you need to add -c conda-forge or otherwise add the conda-forge channel.
See: https://github.com/explosion/spaCy/issues/6638
There was some problem while loading some library which was some prerequisite for spacy.
The problem was solved by calling the file via terminal with the following command;
LD_PRELOAD=/usr/lib/arm-linux-gnueabihf/libatomic.so.1.2.0 python3 main.py
I have python 3.5 installed on my Linux Mint (Ubuntu 16.04 Xenial)
I also had installed protobuf installed using pip3 install protobuf
I installed tensorflow using pip3 install tensorflow
Then I tried to import tensorflow in python 3 it failed with error presented below:
Traceback (most recent call last):
File "/home/abdullah/face_recognition/tensorflow_test.py", line 1, in <module>
import tensorflow
File "/usr/local/lib/python3.5/dist-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/__init__.py", line 83, in <module>
from tensorflow.python.estimator import estimator_lib as estimator
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/estimator/estimator_lib.py", line 35, in <module>
from tensorflow.python.estimator.inputs import inputs
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/estimator/inputs/inputs.py", line 22, in <module>
from tensorflow.python.estimator.inputs.numpy_io import numpy_input_fn
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/estimator/inputs/numpy_io.py", line 22, in <module>
from tensorflow.python.estimator.inputs.queues import feeding_functions
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/estimator/inputs/queues/feeding_functions.py", line 40, in <module>
import pandas as pd
File "/usr/local/lib/python3.5/dist-packages/pandas/__init__.py", line 23, in <module>
from pandas.compat.numpy import *
File "/usr/local/lib/python3.5/dist-packages/pandas/compat/__init__.py", line 361, in <module>
from dateutil import parser as _date_parser
File "/usr/local/lib/python3.5/dist-packages/dateutil/parser.py", line 158
l.append("%s=%s" % (attr, `value`))
^
SyntaxError: invalid syntax
Consulting through many questions posted on SO and other forums, I tried uninstalling protobuf then I encountered following error.
Traceback (most recent call last):
File "/home/abdullah/face_recognition/tensorflow_test.py", line 1, in <module>
import tensorflow
File "/usr/local/lib/python3.5/dist-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/__init__.py", line 52, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "/usr/local/lib/python3.5/dist-packages/tensorflow/core/framework/graph_pb2.py", line 6, in <module>
from google.protobuf import descriptor as _descriptor
ImportError: No module named 'google.protobuf'
At the moment I'm just a beginner for all of this. I don't why protobuf is required why do all this hassle? I just wanted to get tensorflow installed on my system and try to learn something.
I was also facing the same problem. The problem I think is this is using pandas from system(apt-get) repository which is not compatible with other libraries. Updating pandas do the trick.
pip3 install --upgrade pandas
Also in your case, if only doing above fails, you can also try to reinstall tensorflow and protobuf with upgrade option.
pip3 install --upgrade protobuf
pip3 install --upgrade tensorflow
I just installed TensorFlow on my system today (Ubuntu 16.04 LTS) using VirtualEnv.
Did you run$ sudo apt-get install python3-pip python3-dev
If so, then try $ pip3 install -upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.4.0-cp35-cp35m-linux_x86_64.whl
Worst comes to worse, you could simply uninstall TensorFlow using $ sudo pip3 uninstall tensorflow and then try reinstalling to see if it corrects any errors.
I am trying to import keras it gives me an error from tensorflow.python.ops import tensor_array_ops.
>>> import keras
Using TensorFlow backend.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/ss/anaconda2/envs/kerasenv/lib/python2.7/site-packages/keras/__init__.py", line 2, in <module>
from . import backend
File "/home/ss/anaconda2/envs/kerasenv/lib/python2.7/site-packages/keras/backend/__init__.py", line 67, in <module>
from .tensorflow_backend import *
File "/home/ss/anaconda2/envs/kerasenv/lib/python2.7/site-packages/keras/backend/tensorflow_backend.py", line 4, in <module>
from tensorflow.python.ops import tensor_array_ops
ImportError: cannot import name tensor_array_ops
I really appreciate if someone can help me to solve this error.
Thanks.
Try: sudo pip install tensorflow --upgrade
You may be using an older version of TensorFlow.
Did you install tensorflow at all?
Could you try installing the lastest version? There is how:
pip install git+git://github.com/tensorflow/tensorflow
pip install git+git://github.com/fchollet/keras.git --upgrade
If this doesn't work I do recommand using theano as a backend, it worked well for me.
There is how to setup it easily:
pip install git+git://github.com/Theano/Theano
pip install git+git://github.com/fchollet/keras.git --upgrade
pip install tensor
Before you do anything else, start python and import keras. Once keras is imported a new file will be created. You can then execute this command:
vi .keras/keras.json
Once the file is open, change tensorflow for theano and you are ready to go.
Update the problem:
I use
sudo python3
>>import numpy
It works!
And I use the suggestion of below comments :
delete the /usr/local/lib/python2.7/site-packages in path.
and the problem solved!
======== the old problem ===========
I'm using Mac OS El Capitan.
The Python2.7 is the default version; python3.5 is installed from the official site python3.5 for mac.
I have already installed numpy in python2.7. Now I need to install numpy in python3.5.
I use:
pip3 install numpy
which return
"Requirement already satisfied (use --upgrade to upgrade):
numpy in /usr/local/lib/python2.7/site-packages"
and when I run
python3
>>import numpy
in python3
it outputs:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/numpy/__init__.py", line 170, in <module>
from . import add_newdocs
File "/usr/local/lib/python2.7/site-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/usr/local/lib/python2.7/site-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/usr/local/lib/python2.7/site-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/usr/local/lib/python2.7/site-packages/numpy/core/__init__.py", line 6, in <module>
from . import multiarray
ImportError: dlopen(/usr/local/lib/python2.7/site-packages/numpy/core/multiarray.so, 2): Symbol not found: _PyBuffer_Type
Referenced from: /usr/local/lib/python2.7/site-packages/numpy/core/multiarray.so
Expected in: flat namespace
in /usr/local/lib/python2.7/site-packages/numpy/core/multiarray.so
It link the 2.7 package.. and show error.
(Similar Problem happens when I install scipy and sklearn)
How to solve the problem?
I ran into the same problem. Uninstalling numpy using pip3, and reinstalling, fixed the issue.
pip3 uninstall numpy
pip3 install numpy
An easy way to avoid this is to install all these modules using anaconda.
https://www.continuum.io/downloads
It will avoid you the headache of installing manually.
Built tensorflow 0.7 from source on Ubuntu 15.10, Cuda 7.5, cudnn 4.0, python 2.7. Bazel build and pip package generation OK. pip install ok. Python script "import tensorflow" fails:
Traceback (most recent call last):
File "/home/keith/Desktop/tf1.py", line 8, in <module>
import tensorflow as tf
File "/usr/local/lib/python2.7/dist-packages/tensorflow/__init__.py", line 23, in <module>
from tensorflow.python import *
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py", line 35, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "/usr/local/lib/python2.7/dist-packages/tensorflow/core/framework/graph_pb2.py", line 16, in <module>
from tensorflow.core.framework import attr_value_pb2 as tensorflow_dot_core_dot_framework_dot_attr__value__pb2
File "/usr/local/lib/python2.7/dist-packages/tensorflow/core/framework/attr_value_pb2.py", line 16, in <module>
from tensorflow.core.framework import tensor_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__pb2
File "/usr/local/lib/python2.7/dist-packages/tensorflow/core/framework/tensor_pb2.py", line 16, in <module>
from tensorflow.core.framework import tensor_shape_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__shape__pb2
File "/usr/local/lib/python2.7/dist-packages/tensorflow/core/framework/tensor_shape_pb2.py", line 22, in <module>
serialized_pb=_b('\n,tensorflow/core/framework/tensor_shape.proto\x12\ntensorflow\"z\n\x10TensorShapeProto\x12-\n\x03\x64im\x18\x02 \x03(\x0b\x32 .tensorflow.TensorShapeProto.Dim\x12\x14\n\x0cunknown_rank\x18\x03 \x01(\x08\x1a!\n\x03\x44im\x12\x0c\n\x04size\x18\x01 \x01(\x03\x12\x0c\n\x04name\x18\x02 \x01(\tB/\n\x18org.tensorflow.frameworkB\x11TensorShapeProtosP\x01\x62\x06proto3')
TypeError: __init__() got an unexpected keyword argument 'syntax'
Any thoughts?
Thanks
This does look like a protobuf library versioning error. There's a long thread on similar issues here:
https://github.com/tensorflow/tensorflow/issues/11
Towards the end there are some suggested solutions that might help.
I succeed in running TensorFlow 0.7 on a manjaro linux laptop using cuda acceleration by running python with optirun:
$optirun python
However, I had problem with protobuf and I had to uninstall/reinstall previous version of protobuf and tensorflow with pip. http://bit.ly/1RHApU5
This is because of protobuf version conflict:
for me i had python-protobuf v2.6.1 installed from apt-get package manager
and while installing tensorflow it installed protobuf v3.3.0 from pip manager
so i uninstalled both:
sudo pip uninstall protobuf
sudo apt-get remove python-protobuf
Reinstalled using pip and it solved the issue!!!
sudo pip install protobuf
Hope this helps..