scipy.io.loadmat doesn't work - python

I have some problems loading mat files into spyder environment. I update my conda version and OS system (now I have Windows 10) and my script doesn't work anymore.
This is the script:
import scipy.io as sio
# I do a lot of stuff here
file = "filename.mat"
a = sio.loadmat(file)
I have found that there is a problem with the loadmat routine, but I don't know what.
I have this information about the system:
OS: Windows 10, 64 bits.
Anaconda 2, python 2.7
Other related software installed: Visual Studio 2015
It works before system operation update. Previus version was Windows 7, 64 bits
The error message when load line is executing: "Apparently the core died unexpectedly. Use 'Restart the core' to continue using this terminal."
UPDATE 1:
I have tested in a laptop the same situation, i.e., windows updating as well anaconda. The same problem with scipy.io.loadmat
UPDATE 2:
I installed an older version of anaconda. IT WORKS!!... Does somebody know what to do now?
Regards

This is a bug in the new scipy. You should downgrade it by running this in the Command Prompt:
conda install scipy==0.16.0

Related

Problems with importing netcdf4 and xarray when debugging - in eclipse + pydev on windows

I have been a staunch user of Eclipse on Windows - mostly for developing Python code. Lately, I needed to do something with the packages xarray and netcdf4. I first used an old version of Eclipse, but when I encountered problems I installed the latest LiClipse - version 8.2.0 (64 bits) on my Windows 10 machine. I use Miniconda 3 py37_4.9.2 (64 bits) with Anaconda Navigator 2.1.2 to manage my Python environments. I wrote a script of only a few lines. When I tried to import package netcdf4, I got an import error immediately that one of the netcdf4 DLLs could not be found after pressing the debug button. When I tried working without direct involvement of netcdf4 but only with xarray, I also got an import error that my packages were not configured correctly. When I started the script - outside Eclipse - from the command-line, there was no problem at all. BTW, I tried running with different Python versions: 3.6, 3.8 and 3.9 but that made no difference. I suspect that Pydev does not work together well with the packages netcdf4 and xarray. Has anybody else experienced similar problems?
It seems like some environment variable isn't properly set when running from PyDev...
Do you have the flag to load conda environment variables set in the interpreter configuration?
i.e.:
Note: if it runs in the command line you can compare the values you have in os.environ from one to the other to find what may be different (in general just making sure that the conda environment variables are loaded should do the trick, but if it doesn't comparing those and setting what's needed in the Environment tab may help).

Using non-macOS version of tensorflow on mac m1

I recently purchased a new mac laptop with the M1 core. I've previously done work using tensorflow, and am trying to continue with my new laptop. I'm aware that apple has a tensorflow_macos version of tensorflow, but unfortunately for my project I need higher order derivatives, which the fork is not currently capable of doing. Is there a way to run the non_mac specific version of tensorflow on a M1?
If I attempt to import tensorflow from an arm terminal, I get the error:
python3
import tensorflow
zsh: illegal hardware instruction python3
The same happens if I run from a Rosetta terminal.
I've also tried running from PyCharm (with a Python 3.8 virtual environment), but I receive a different problem on trying to import tensorflow:
Process finished with exit code 132 (interrupted by signal 4: SIGILL)
I have python3.8.5 installed. I've seen on other related questions that there should be two versions of python3 installed by default on mac (arm and x86_64), but it looks like I only have one version:
file $(which python3)
/Users/xxx/opt/miniconda3/bin/python3: Mach-O 64-bit executable x86_64
I'm inexperienced when it comes to handling different core architectures, so any advice would be appreciated. I'm happy to provide clarification for any specifics.

Simple ITK Elastix installation on Windows 10 from Sources with CMake to run in Python

I have to try to install SimpleITK Elastix on Windows 10. I have the toolchain (Windows 10, Anaconda3, python 3.7 , MSVS 2019, Cmake 3.7, git,) and source code (SimpleITK v1.2, SimpleElastix KIT). It do all steps all right but after run python setup install I open python interpreter shell for list the modules of SimpleITK package print (dir(istk)) and the modules 'Elastix', 'ElastixImageFilter', 'ElastixImageFilter_swigregister' are not listed. I have tried on Ubuntu 18.04 and I have goten it. I have tried why the same process work on Ubuntu 18.04 and not on Windows 10, but I don't see differences. I need work with SimpleElastix kit on Windows 10, I have list the location of packages and the results are
import sys
sys.path
['', 'C:\\Users\\usuario\\Anaconda3\\python37.zip', 'C:\\Users\\usuario\\Anaconda3\\DLLs', 'C:\\Users\\usuario\\Anaconda3\\lib', 'C:\\Users\\usuario\\Anaconda3', 'C:\\Users\\usuario\\Anaconda3\\lib\\site-packages', 'C:\\Users\\usuario\\Anaconda3\\lib\\site-packages\\simpleitk-1.2.0rc2.dev1167+gd4cf2-py3.7-win-amd64.egg', 'C:\\Users\\usuario\\Anaconda3\\lib\\site-packages\\win32', 'C:\\Users\\usuario\\Anaconda3\\lib\\site-packages\\win32\\lib', 'C:\\Users\\usuario\\Anaconda3\\lib\\site-packages\\Pythonwin']
I can see the package 'C:\Users\usuario\Anaconda3\lib\site-packages\simpleitk-1.2.0rc2.dev1167+gd4cf2-py3.7-win-amd64.egg'. I think that Elastix modules are anywere in the file system but python dont get to load them.
Can you help me, please? Thanks in advance. PD: I am trying to install this library for a week :(
great day for me. The post Install SimpleElastix on Windows for Python is the solution. Specifically the first point:
1- Re-install Anaconda3, add to PATH while installing (although it's not recommended by the installer). Make sure Python can be accessed by the system by checking in cmd. Just type "python" and see if its version pops out.
I would like know why reinstalling Anaconda its the solution. Heuristic method for not experts but the solution its not in the FAQs of tool sources.
Thanks a lot to stackoverflow
Cándido

Enthought Install Canopy Windows 7 Fails Parse Error Invalid Line

I've been trying to install Canopy 64-bit on a Win 7 64bit machine. I downloaded both the quick install and the academic version. They both appear to install but fail to launch. The error message is:
Unexpected error ParseError:Invalid line line "1"
I uninstall the earlier versions of Canopy, but I'm reluctant to uninstall all my Python installations. Canopy doesn't answer bug reports and I can't afford to sacrifice my entire Python build just to get the benefits of Canopy.
During installation, I am never given the option of 'run as administrator'. I install from msi files, which don't appear to have an run-as-admin option.
Does this happen to anybody else, or do I just need to give up on Enthought?
Thanks, KC
(Update below)
Solution (offline communication with OP):
Log out of Windows. Log back in. Delete this directory:
C:\Users\<your-user-name>\Appdata\Roaming\Enthought\Canopy\
and restart Canopy.
This solution is a blunt axe. More precise solution to be posted when verified.
=== Updated November 2, 2013:
Log out of Windows. Log back in. Delete this file:
C:\Users\<your-user-name>\Appdata\Roaming\Enthought\Canopy\preferences.ini
and restart Canopy.

installing IPython with two versions of Python (Windows)

Is it possible to have IPython (0.12) installed on the same
system with two different versions of Python (v 2.7 and 3.2)? Currently I have both versions of Python running happily on my system.
I am using two machines, one with Windows 7 64-bit, the other XP SP2 32-bit, and both have Python 2.7.2 and 3.2 installed. I have been using IPython with Python 2.7 w/o any problems for a while on both.
Now I would like to have 3.2 available too with IPython, but when I try to run the binary windows IPython installer I get this error toward the end of the install:
*** run_installscript: internal error 0xFFFFFFFF ***
and no shortcuts/entries into Start Menu etc are created.
(I ran the install as adminstrator under Win 7) I am running into the same problem with XP and Win 7.
After poking around the net and SO for a while I saw references for
getting setuptools. Unfortunately, there's no version for Python 3.x
but it was suggested to use distribute.py instead which I ran and
installed. I am not sure how to proceed next. And I'm not even sure it
is possible to do this (though I think it is :)
Any suggestions?
UPDATE: There was a problem with import readline not working with Python 3.2.3, but I was able to fix it by downloading pyreadline-2.0-dev1.win32.exe which works with Python 3.2.3 .. the above problem remains unfortunately.
Ok, here's my solution to get IPython 0.12.1 to work with both Python ver
2.7.x and 3.2.x on the same system (ie. under Windows 7 64 bit and XP SP2 32 bit). It's not
perfect, but works, and hopefully will help others. Where I am showing directories they refer to XP (but should be adjusted accordingly for Windows 7)
Steps for both:
Install both versions of Python via the binary windows installer provided at
Python.org
Install this version of pyreadline pyreadline-2.0-dev1.win32.exe which works
for both versions of Python (I could not get the widely available version 1.7 to work with Python 3.2.x)
I am not sure if distribute.py is necessary, I'd skip it on the
first try.
Download ipython-0.12.1.zip file and extract it. Place it under your Programs directory and cd into it (I'll call this the ipython_dir) [I tried the binary installer numerous times without success]
For Python 3.2 (easier)
In the ipython_dir:
c:\python32\pyton.exe setup.py install
will create ipython3.exe in c:\python32\Scripts that can be used to
fire up iPython
For Python 2.7 (a bit odd)
The above method failed. However, it is possible to start IPython from the ipython_dir with
c:\python27\python.exe ipython.py
I can't explain why this is so, but since I use Console2 I can hide
these two ways of starting IPython.
Summary:
To start IPython with v 2.7.x of Python:
c:\python27\python.exe "C:\Program Files..\ipython_dir\ipython.py"
To start IPython with v 3.2.x of Python:
c:\python32\Scripts\python3.exe
That was a lot of work and took most of the day, so I hope posting the steps above
will save someone else a lot of time (and help me remember what I have to do next time I struggle with this)
Thanks everyone for their suggestions.
Addendum: None of the above resulted in shortcuts or entries in the Start/Program Menus. Shortcuts can be created manually, or in my case aren't necessary since I'm using a special shell (Console2) to run IPython.
The first question in the iPython FAQ titled "Running IPython against multiple versions of Python" may help.

Categories

Resources