Incompatibility of Latest version of Anaconda with Python and other libraries - python-3.x

I used to use Anaconda 4.3.1 (64-bit) along with Python 3.6.0 and have written several codes and all of them worked fine. I also used Jupyter (Notebook Server 5.0.0) and Spyder too. They all work and my codes were able to run correctly. After recent updates on Anaconda, Spyder and Python all my recent Python codes (those worked before the updates) are not working.
Any Suggestions?
Could you please let me know how I can go back to Anaconda 4.3.1 with Python 3.6.0?
Thank you in advance for an early reply.
Best Regards
I uninstalled and did fresh installation of Anaconda a few times but no
changed with same errors.
Please see below for the error messages:
(TypeError Traceback (most recent call last)
D:\Software\AnacondaDistribution\Anaconda\lib\site-packages\matplotlib\colors.py in to_rgba(c, alpha)
131 try:
--> 132 rgba = _colors_full_map.cache[c, alpha]
133 except (KeyError, TypeError): # Not in cache, or unhashable.
TypeError: unhashable type: 'numpy.ndarray'
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last)
D:\Software\AnacondaDistribution\Anaconda\lib\site-packages\matplotlib\axes_axes.py in scatter(self, x, y, s, c, marker, cmap, norm, vmin, vmax, alpha, linewidths, verts, edgecolors, **kwargs)
4049 # must be acceptable as PathCollection facecolors
-> 4050 colors = mcolors.to_rgba_array(c)
4051 except ValueError: )
matplotlib should plot the figure without any issues.

Related

Wandb not initializing on Nvidia Pytorch Image arm64

I'm having serious problems with wandb on a nVidia pytorch image using arm64 architecture. No info online on how to solve this problem. Cannot even start a project with wandb.init()
[python error]: https://i.stack.imgur.com/pdgDT.png
AttributeError Traceback (most recent call last)
in
1 #!pip install wandb
2 import wandb
----> 3 wandb.init(project='gpt3')
AttributeError: module 'wandb' has no attribute 'init'
It seems wandb hasn't been installed correctly in your case.

AttributeError: module 'tensorflow' has no attribute 'gfile' even with tensorflow v1

I am having a problem as i upload my model in drive and mount it in Colab module imports are working fine in previous cell as i gave the root path and sys.append() it , I am using (tf.compat.v1) you can see it in ouptut, but still getting this error also tried (tensorflow v2) and used tf.io.gfile but still same error. Kindly help me
<module 'tensorflow_core.compat.v1.version' from '/usr/local/lib/python3.6/dist-packages/tensorflow_core/_api/v2/compat/v1/version/__init__.py'>
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-7-e851eb463895> in <module>()
1 print(tf.version)
----> 2 category_index = label_map_util.create_category_index_from_labelmap(PATH_TO_LABELS, use_display_name=True)
2 frames
/content/drive/My Drive/models/research/object_detection/utils/label_map_util.py in load_labelmap(path)
136 a StringIntLabelMapProto
137 """
--> 138 with tf.gfile.GFile(path, 'r') as fid:
139 label_map_string = fid.read()
140 label_map = string_int_label_map_pb2.StringIntLabelMap()
AttributeError: module 'tensorflow' has no attribute 'gfile'
Try to downgrade TF 1.15 from TF 2.x, your issue will be resolved.
Please refer code as shown below
!pip uninstall tensorflow
!pip install tensorflow==1.15
import tensorflow as tf
If you are looking for simple solution for Colab, please use %tensorflow_version 1.x magic command, which does for you without un-installation.
%tensorflow_version 1.x
import tensorflow as tf

How to fix "AttributeError: module 'chart_studio.tools' has no attribute 'make_subplots'"

I am using python 3.7, plotly 3.8.1 and cufflinks 0.15 and got the below error, please kindly help.
Ipython code -
calls.set_index('STRIKE_PRC')[['CF_CLOSE', 'IMP_VOLT']].iplot(subplots=True,
mode='lines+markers',size=6)
error code-
AttributeError Traceback (most recent call last) in
C:\Users\George
Lo\AppData\Roaming\Python\Python37\site-packages\cufflinks\tools.py in
get_subplots(rows, cols, shared_xaxes, shared_yaxes, start_cell,
theme, base_layout, **kwargs)
892
893 layout= base_layout if base_layout else getLayout(theme,**check_kwargs(kwargs,__LAYOUT_AXIS))
--> 894 sp=py.plotly.tools.make_subplots(rows=rows,cols=cols,shared_xaxes=shared_xaxes,
895 shared_yaxes=shared_yaxes,print_grid=False,
896 start_cell=start_cell,**kwargs)
AttributeError: module 'chart_studio.tools' has no attribute
'make_subplots'
This is a bug with integration between plotly 3.8.X and was reported on the cufflinks github issue tracker. A fix was merged, but I don't think that it is released yet.
Edit: 09/05/19 and 21/06/19 Updated my conda environment, but the bug remains.

How to fix 'cannot initialize type TensorProto DataType' error while importing torch?

I installed pytorch using pip3 command for my windows pc without GPU support.
But when I tried to import torch it is giving an error.
At first, there was a different error saying numpy version not matching and I updated the numpy to the latest version.
import torch
RuntimeError Traceback (most recent call last)
<ipython-input-10-c031d3dd82fc> in <module>()
----> 1 import torch
C:\Users\iamuraptha\Anaconda3\lib\site-packages\torch\__init__.py in <module>()
82 pass
83
---> 84 from torch._C import *
85
86 __all__ += [name for name in dir(_C)
RuntimeError: generic_type: cannot initialize type "TensorProtoDataType": an object with that name is already defined
I reinstalled anaconda and then created a virtual environment for pytorch.Now everything works fine
If you are running this in colab, remember to restart your runtime after installing your modules with pip.

igraph plot function does not show images in an IPython notebook

I try to do a basic igraph plotting in an IPython notebook:
fn = 'misrables.gml'
gr = igraph.Graph.Read_GML(fn)
igraph.plot(gr)
instead of seeing a graph I see this:
Out[7]: <igraph.drawing.Plot at 0x1120d6978>
How do I persuade IPython to actually show the graphics?
Some clarifications
Inline matplotlib works fine, so this is not the issue.
I have cairo installed:
import cairo
cairo.version
output: 1.10.0
Calling _repr_svg() on the plot object results in an error:
TypeError Traceback (most recent call last)
/Users/boris/Documents/workspace/communityAnalysis/src/utils.py in <module>()
----> 1 z = ig.plot(gr)._repr_svg_()
/usr/local/lib/python3.4/site-packages/igraph/drawing/__init__.py in _repr_svg_(self)
362 # No idea why this is needed but python crashes without
363 context.show_page()
--> 364 surface.finish()
365 # Return the raw SVG representation
366 return io.getvalue()
TypeError: string argument expected, got 'bytes'
Do you have the Cairo library and its Python bindings installed on your machine? The Plot object of igraph has a _repr_svg_ method that should be enough for IPython to show the plot, but _repr_svg_ uses Cairo behind the scenes to draw the graph into an SVG file, so if you don't have Cairo, _repr_svg_ probably throws an exception that IPython swallows, and then you get an ordinary repr() representation for the plot.
Update: based on the updated post, it turned out that the problem was that _repr_svg_ was not prepared for Python 3.x as it used a StringIO object where a BytesIO object would have been appropriate. Replacing io = StringIO() with io = BytesIO() at the beginning of the function and replacing return io.getvalue() with return io.getvalue().decode() at the end solves the problem. (from io import BytesIO is also needed at the top of igraph/drawing/__init__.py). A bug report has been filed on GitHub; the issue will be fixed in the next minor release.
Update: the issue is now fixed in the development version; see this commit for a patch.
Update for igraph 0.7.1 in python 3.7.4 and IPython 7.8.0
if you install the package with:
conda install python-igraph
Then you can simply use
igraph.plot(gr).show()
and in Ubuntu a .png will be displayed automatically in a separate window with ImageMagick

Resources