I'm trying to install IPython notebook on OS X 10.10.2.
After all dependencies have been added, this error occurs:
File "/Library/Python/2.7/site-packages/jinja2/tests.py", line 14, in <module>
from jinja2._compat import text_type, string_types, integer_types
ImportError: cannot import name integer_types
How can I fix this?
How are you installing ipython?
If you have pip, are you using pip install ipython[all]?
I also recommend using virtualenv to start with a completely clean python2.7 install from scratch and see if you encounter the errors still. There may be some version compatibility conflicts on the system.
Alternative is you can install the Anaconda distribution which comes prepackaged with ipython and dependencies http://continuum.io/downloads
Related
I have installed python 3.7 and want to do some forecasting using fbprophet (https://facebook.github.io/prophet/docs/installation.html#python)
But I get this error when installing the package using the command (pip install fbprophet)
import pystan
File "e:\repos\usf\venv\lib\site-packages\pystan\__init__.py", line 9, in <module>
from pystan.api import stanc, stan
File "e:\repos\usf\venv\lib\site-packages\pystan\api.py", line 13, in <module>
import pystan._api # stanc wrapper
ImportError: DLL load failed: The specified module could not be found.
I have done some research and got to know that this is possible with conda. But I am looking for a solution without using conda.
Thanks in advance.
It says in the Pystan documentation that configuring a C++ compiler can be challenging on Windows. Following approach worked for me to install Pystan 2.17.1 and FBProphet 0.6:
Install C++ compiler, mingw-w64 (http://mingw-w64.org/doku.php/download) -> I selected this one https://sourceforge.net/projects/mingw-w64/files/
Add C:<MinGW_w64 installation directory>\bin to the PATH environment variable
Create a distutils.cfg file with the following contents in the folder \Lib\distutils in Python install directory (in venv):
[build]
compiler=mingw32
[build_ext]
compiler=mingw32
pip install numpy cython
pip install pystan==2.17.1
Verify the Pystan installation (https://pystan.readthedocs.io/en/latest/windows.html)
pip install fbprophet==0.6
Follow https://github.com/facebook/prophet/issues/1939
I had similar issues even after installing Mingw
conda install libpython m2w64-toolchain -c msys2
Solved all the errors and i am able to install fbprophet finally
Thanks
I had similar issues with my Python3.6 (anaconda)
I reinstalled anaconda for all users (with admin privileges) then
"conda install -c conda-forge pystan"
later i updated all other modules
it works without any error now
I am new to python and was using a python script written by someone else. I was running it fine in a different PC. Just had to install coupe of packages including pip3, google-cloud, google-cloud-bigquery and pandas.
Now when I installed the same packages on a different PC, I am unable to run the script. It is showed the following error first:
module = 'google.protobuf.descriptor_pb2' TypeError: expected bytes, Descriptor found
However, when In purged/re-installed/updated packages and also added protobuf3 and protobuf-py3 package, The error has been updated to the following message:
from google.cloud import bigquery
File "/home/mobeen/.local/lib/python3.6/site-packages/google/cloud/bigquery/__init__.py", line 35, in <module>
from google.cloud.bigquery.client import Client
File "/home/mobeen/.local/lib/python3.6/site-packages/google/cloud/bigquery/client.py", line 50, in <module>
import google.cloud._helpers
File "/home/mobeen/.local/lib/python3.6/site-packages/google/cloud/_helpers.py", line 33, in <module>
from google.protobuf import duration_pb2
File "/home/mobeen/.local/lib/python3.6/site-packages/google/protobuf/duration_pb2.py", line 8, in <module>
from google.protobuf import symbol_database as _symbol_database
File "/home/mobeen/.local/lib/python3.6/site-packages/google/protobuf/symbol_database.py", line 193, in <module>
_DEFAULT = SymbolDatabase(pool=descriptor_pool.Default())
AttributeError: module 'google.protobuf.descriptor_pool' has no attribute 'Default'
.Any help or leads in this will be appreciated
I solved the problem by uninstalling protobuf:
pip3 uninstall protobuf
pip3 uninstall python3-protobuf
NB: You should repeat this command until you get a message that there is no package named protobuf.
After that execute:
pip3 install protobuf
Install just the protobuf , don't install python3-protobuf
Hope this solution can help you.
I solved it by first executing twice
pip3 uninstall protobuf
The second time the terminal returned
Found existing installation: protobuf 3.6.1
Not uninstalling protobuf at /usr/lib/python3/dist-packages, outside environment /usr
Can't uninstall 'protobuf'. No files were found to uninstall.
Then I removed protobuf manually
sudo rm -r /usr/lib/python3/dist-packages/google/protobuf*
sudo rm -r /usr/lib/python3/dist-packages/protobuf*
And finally I executed
pip3 install --upgrade protobuf
And the problem was solved
Did you try this too?
"I solved the problem of showed Attribute Error: 'module' object has no attribute 'Default' when import tensorflow after installed by delete redundant protobuf file.
The reason is some google/protobuf/descriptor_pool.py do not have a 'Default' defined. This usually happened at old version of protobuf so I upgraded successfully, but problem not solved. And by checking PATH and search about 'google/protobuf', I found it existed in both "/usr/local/lib/python2.7/dist-packages/google/protobuf/" and "/usr/lib/python2.7/dist-packages/google/protobuf/". Previous one have attribute 'Default' but the second one not.
I tried import google.protobuf and google.protobuf.file, It shows '/usr/lib/python2.7/dist-packages/google/protobuf/init.pyc'. I deleted /usr/lib/python2.7/dist-packages/google/protobuf and tried to import tensorflow, worked."
Actually I've ran into a similar case, we had 2 packages installed protobuf and python3-protobuf. I actually dont know the root cause for this but apparently when you do that:
pip install protobuf
pip install python3-protobuf
that error you described is happening, looks like it gives you some different version, like those two packages have overlapping files, and they override each other or something.
the solution for me was simply to reverse the installation order (make sure to uninstall them both first):
pip install python3-protobuf
pip install protobuf
or just
pip install python3-protobuf protobuf
hope this helps anyone here.
The reason can be that the interpreter that you are using to run the python programm uses the previous version of google.protobuf
You can assure it to run in the interpreter
>>> import google.protobuf
>>> print google.protobuf.__version__
Then compare it running in the terminal
$pip show protobuf
If the versions are different that's the reason
So I suggest deleting this package right from the python interpreter console
>>> pip uninstall protobuf -y
After you can even install the package right from the python console
>>> pip install protobuf
After that you good to go ✌️
Everything was working smoothly until I started getting the following error:
Traceback (most recent call last):
File "", line 1, in
File "/home/user/Workspace/Practices/Tensorflow/tensorflow2/venv/lib/python3.7/site-packages/tensorflow/init.py", line 98, in
from tensorflow_core import *
File "/home/user/Workspace/Practices/Tensorflow/tensorflow2/venv/lib/python3.7/site-packages/tensorflow_core/init.py", line 40, in
from tensorflow.python.tools import module_util as _modle_util
ModuleNotFoundError: No module named 'tensorflow.python.tools'; 'tensorflow.python' is not a package
My environment setup:
python-3.7
Using venv module to create virtual environment
tensorflow 2.0.0
pip 19.0.3
Manjaro Linux
Now, I even can't import tensorflow module as well. It gives same above error. Tried reinstalling with cache and without cache as well, but no luck. Recreated virtual environment as well, no luck. This is really weird and have no clue where to start troubleshooting as well. Looking at virtual environment site packages, everything seems fine.
I just faced this problem right now. I ran the source code on another computer and it showed the same error. I went ahead and compared the version of TensorFlow and turns out that the other computer was running tensorflow==2.1.0 and mine was running tensorflow==1.14.0.
In short, downgrade your tensorflow installation (pip install tensorflow==1.14.0)
Found a noob problem. I was using my file name as csv.py which already exist in python library, which I think was messing up the paths. But don't know how yet.
Try uninstalling and reinstalling. First run:
pip uninstall tensorflow
then reinstall:
pip install tensorflow==2.0
After you uninstall, in the python shell, run:
help('modules')
TensorFlow should not be there in that list. Only then proceed to install it.
You don't need to uninstall tensorflow what version you have because it will take time to reinstall. You can fix this issue just by installing tensorflow==2.0.
pip install tensorflow==2.0
I have anaconda installed on my Win 7 machine with a GTX1070.
I have been trying to install tensorflow gpu version for the past hour with no luck. I followed the tutorials on the tensorflow website to no success. They ask for you to install CUDA 8.0 and Cudll 6.0 which I do. I then add the location of cudnn64_6.dll, cudart64_80.dll and the libnvvp folder to my path variables. I then set up a virtual environment in conda and run the following command:
(tensorflow)C:> pip install --ignore-installed --upgrade tensorflow-gpu
I believe when I do this, it installs tensorflow 1.5 which seems to require CUDA tools 9.0 because I get an error saying that cudart64_80.dll cannot be found. So I update my CUDA tools to 9.0 and download the corresponding Cuda library. I then change my path variables. Now I dont get any missing dll errors however, I am now faced with the following error
ModuleNotFoundError: No module named 'absl'
Does anyone have any suggestions as to what I can do from here on?
This was caused by a Python version issue for me. I had the absl package installed on my Python 2.x, but my Python 3.x didn't have it. So I just made sure that both Pythons on my machine had the package installed:
pip install absl-py
pip3 install absl-py
Here is how I solved it in my end.
I was getting the error even though absl-py was already installed.
When I used pip install absl-py I got the following error:
Requirement already satisfied: absl-py in c:\users\stack\appdata\local\programs\python\python38\lib\site-packages (0.9.0)
Requirement already satisfied: six in c:\users\stack\appdata\local\programs\python\python38\lib\site-packages (from absl-py) (1.15.0)
I fixed it by reinstalling, i.e. by using:
pip uninstall absl-py
pip install absl-py
Then I faced a similar error with wrapt:
ModuleNotFoundError: No module named 'wrapt'
Fixed wrapt as well by uninstalling and then installing it again.
pip uninstall wrapt
pip install wrapt
Try:
conda install tensorflow
conda install -c anaconda absl-py
This worked for me.
For more information see: https://anaconda.org/anaconda/absl-py
I was facing the same issues and pip (or pip3) install absl-py was not working.
python --version showed I was using the wrong python version (2.7). So I changed the python version to 3.5 (https://askubuntu.com/questions/320996/how-to-make-python-program-command-execute-python-3)
This worked for me.
You can use the Anaconda GUI to install absl-py pack to solve the problem:
Select the uninstall columnand search absl-py to apply it.
Try another version of absl-py. My default absl version is 0.8.1 and python is 3.6:
$pip install absl-py==0.8.0
works for me.
Or change my environment python version to 3.7 also works.
This is quite late but still worth posting. What they don't tell you on the NVidia website is that there is one more path you need to add to your environment variables. The path is;
c:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\extras\CUPTI\libx64
It may not be exactly the same on your installation as it depends on where you installed your CUDA tools.
You could also just use pip to install TF GPU version but pip installs TF 1.1 which is fairly old.
For me, "pip3 install absl-py" don't work:
I received: "ModuleNotFoundError: No module named 'absl' ", when I was trying import tensorflow:
import tensorflow
Traceback (most recent call last):
File "", line 1, in
File "/opt/anaconda3/lib/python3.6/site-packages/tensorflow/init.py", line 22, in
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "/opt/anaconda3/lib/python3.6/site-packages/tensorflow/python/init.py", line 63, in
from tensorflow.python.framework.framework_lib import * # pylint: disable=redefined-builtin
File "/opt/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/framework_lib.py", line 25, in
from tensorflow.python.framework.ops import Graph
File "/opt/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 55, in
from tensorflow.python.platform import app
File "/opt/anaconda3/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 24, in
from tensorflow.python.platform import flags
File "/opt/anaconda3/lib/python3.6/site-packages/tensorflow/python/platform/flags.py", line 25, in
from absl.flags import * # pylint: disable=wildcard-import
ModuleNotFoundError: No module named 'absl'
But if I compile absl-py from scratch, all goes right:
jk#D17:~/py/004/abseil-py-master$ python setup.py install
running install
running bdist_egg
running egg_info
.......
Using /opt/anaconda3/lib/python3.6/site-packages
Finished processing dependencies for absl-py==0.4.0
and then:
import tensorflow
is OK
Find the absl-py related folder in your site-packages folder and delete it. Try reinstalling pip3 install absl-py. I solved this way, I hope to be useful to you.
If you are using Anaconda make sure you install jupyter notebook from Home. if not you can import it from python CLI but it will give "No module named 'absl' error when importing TensorFlow"
In hopes that this might help someone in the future. I had similar issues installing/using tensorflow and by extension the absl python package. There were some issues relating to a pure pip installation so I had to find an alternate route.
This is the process I followed.
Download and install miniconda:
wget https://repo.continuum.io/miniconda/Miniconda3-3.7.0-Linux-x86_64.sh -O ~/miniconda.sh
bash ~/miniconda.sh -b -p $HOME/miniconda
add conda to PATH (Optional):
export PATH="$HOME/miniconda/bin:$PATH"
activate the conda environment:
source $HOME/miniconda/bin/activate
At this point you should have (base) as your sourced condo environment. From this environment perform the following:
conda create -n tensorflow python=3.7
activate tensorflow
Just to note, at this point you should be working in the (tensorflow) environment. It would have replaced the base environment. It is also the env where you would run your tensorflow related job (that failed and brought you here).
pip install --ignore-installed --upgrade tensorflow
pip install absl-py
At this point you might need to install additional dependencies such as numpy.
My goal was to be able to run tensorflow tools and this worked for my ends. Hope it may be useful to someone else in the future.
I got the No module named absl error when I tried to install tf-nightly 2.9.0.dev20220203 on my Ubuntu 20.04.3 machine.
Reinstalling absl-py did not directly worked.
While reinstalling absl, I got this error: ERROR: tf-nightly 2.9.0.dev20220203 has requirement gast<=0.4.0,>=0.2.1, but you'll have gast 0.5.3 which is incompatible.
So I uninstalled absl-py:
pip uninstall absl-py
Then downgraded gast:
pip uninstall gast
pip install gast==0.4.0
Finally,
pip install absl-py
I've used the following tutorial to install Python, numpy, scipy and matplotlib:
https://penandpants.com/2012/03/01/install-python-2/
I downloaded each and installed by double-clicking. I'm using a Mac with OS X Yosemite Version 10.10.5
When I try to import numpy, scipy and matplotlib in IDLE I get the follow error message:
`>>> import numpy
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
import numpy
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/__init__.py", line 137, in <module>
import add_newdocs
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/add_newdocs.py", line 9, in <module>
from numpy.lib import add_newdoc
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/lib/__init__.py", line 4, in <module>
from type_check import *
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/lib/type_check.py", line 8, in <module>
import numpy.core.numeric as _nx
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/__init__.py", line 5, in <module>
import multiarray
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/multiarray.so, 2): no suitable image found. Did find:
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/multiarray.so: no matching architecture in universal wrapper`
Can anyone please explain to me how to resolve this?
Thanks
use terminal and type
sudo pip install numpy
sudo pip install matplotlib
sudo pip install scipy
for python3+ use pip3
I can't say for sure what's wrong with your installation, but I suspect it's due to a some PATH-conusion... Python 2.7 and Numpy should be installed on your Mac by default.
If you run the command which python, you'll see which executable the python-commands invokes... is it the same as the one you installed?
If you write python in the terminal, and press tab twice, do you see multiple options of installed python versions?
Alternative method of installation
I prefer the Anaconda Python Distribution, which you can download like the full version or minimal version, which is the one I prefer.
If you install this, you should consider uninstalling the one you just installed.
Here's how to install the mini version:
Download the installer, and run it by opening a terminal in the folder with the installer, and running the command bash Miniconda2-latest-MacOSX-x86_64.sh. This will start the text-based installer, and if you read the instructions on screen, you'll be fine.
Notice that you have to scroll to the end of the licence agreement, before you can write yes when asked to accept the terms stated.
Say yes when it asked you if you'd like it to add Anaconda Python to your path.
Anaconda Python is different from other python distributions in the regard that it comes with it's own package and environment manager conda. With conda you can have multiple versions of Python installed at the same time (or several environments of the same Python version, but with different packages or versions of packages).
To create a new environment with the name py27, which is using Python 2.7, write conda create -n py27 python=2.7 --yes. Once created, activate the environment by source activate py27.
With the new environment now active, install the packages you need by using conda: conda install scipy matplotlib --yes.
I'd also recommend installing Ipython, which is an improved shell, and possibly the Jupyter notebook: conda install ipython --yes and conda install notebook --yes.
Hope it helps.