These are chat archives for spyder-ide/public

3rd
Jan 2019
rivitalee
@rivitalee
Jan 03 13:06
hellow, is there anyone who knows that how can I import module cv2 in spyder? cos it's not work. I've tried to download it via anaconda
NdaAzr
@NdaAzr
Jan 03 13:18
@CAM-Gerlach Still I couldn't find any direct solution to be able yo see inside the tensor object of torch module in spyder after reading spyder-ide/spyder#7042 . could you please guide me to the direct solution for this?
@rivitalee if you work with spyder through anaconda you need to write import cv2. this is an example which works for me . import cv2
m = cv2.imread('D:\Neda\Pytorch\U-net\my_data\labelsResized\image_labeled_1.png')
img = np.array(m)
CAM Gerlach
@CAM-Gerlach
Jan 03 15:44
@rivitalee Check to make sure it works outside of Spyder (e.g. in a jupyter qtconsole instance opened in the same environment in which Spyder is installed) and read our Guide to Packages and Environments in Spyder.
CAM Gerlach
@CAM-Gerlach
Jan 03 16:13
@NdaAzr The direct solution, as I explain step by step in my comment, is to make a few minor changes to the Spyder codebase to give Spyder the ability to view and edit Tensor objects natively, just like normal Numpy arrays in the Variable Explorer. Then, everyone will be able to take advantage of this feature instead of having to find a hacky workaround. All you would need to do is fork the Spyder repo on Github and create a new feature branch (e.g. tensor-support), make the changes I outline in the above comment, test them locally to make sure they work (see our contributing guide for how to get it up and running), and submit a Pull Request on the main Spyder repo for your feature branch to get your changes merged into Spyder for everyone to use.
NdaAzr
@NdaAzr
Jan 03 16:55
when I import numpy as np in spyder it giving me an error AttributeError: 'Tensor' object has no attribute 'np'. It was working before, any idea?
CAM Gerlach
@CAM-Gerlach
Jan 03 21:39
@NdaAzr Okay, that seems to be a different issue then being unable to display Tensors in the Variable Explorer as you originally reported, unless I'm misunderstanding what you're telling me. So what you're saying in a newly started/restarted console, typing just import numpy as np is giving you that error? Can you copy and paste or provide a screenshot of the full traceback? Its possible there is another file on your path (maybe named numpy.py?) or in memory that's conflicting, its some weird installation issue, or else its some variation of user error.