I want to create neural network and install scipy and PyBrain for it.
On file i write:
from pybrain.tools.shortcuts import buildNetwork
net=buildNetwork(4,2,1)
and when i run that file, an error occured
from scipy.linalq import inv,det, svd, logm, expm2
ImportError: cannot import name expm2
Can you advise something?
Scipy latest version doesn't contain scipy.linalg.expm2. Instead, it has scipy.linalg._expm_frechet. So open up that .py file in Pybrain (pybrain.tools.functions) and replace the line from scipy.linalg import inv, det, svd, logm, expm2 with from scipy.linalg import inv, det, svd, logm, _expm_frechet and it should solve your problem.
This error message is basically saying:
expm2 isn't installed. i.e. Your scipy version hasn't got expm2 or something went wrong during the installation.
Try reinstalling scipy, that should do it.
The function scipy.linalg.expm2 used by PyBrain has been deprecated since v.0.13 and has been removed in v.1.0.0 (not yet released):
The deprecated functions expm2 and expm3 have been removed from
scipy.linalg.
(In section "Backwards incompatible changes")
As it seems that PyBrain has not been updated yet, you need to fall back to a Scipy version that still contains this function, such as the last release v.0.19.1.
I had the same error. I don't know if it is still relevant, but for me the error dissapeared when I changed expm2 to expm.
Just to make things easier for everyone out there trying this solution:
in the python console after installing the pybrain library, type pybrain.tools.functions as the attached figure is showing up
after the word "from" between simple quotes is your file path for the .py functions file used as show on the figure
File path shown on the python console
open it up and press CTRL + F to search for the expm2 reference in the import statement amongst the first lines of code in the file
on the import statement for expm2, replace expm2 for _expm_frechet as shown on the figure
Replacement of expm2 for _exp_frechet
now, try running your code again and jupyter lab should work with the pybrain library
To solve this problem u can do it:
Find the file "functions.py" in
"C:\Users<user-name>\AppData\Local\Programs\Python\Python310\Lib\site-packages\pybrain\tools"
Find this command "from scipy.linalg import", and then change "expm2" to "expm", do it in this function too "def sqrtm(M)":
"expm2(0.5 * logm(M)" to "expm(0.5 * logm(M)".
Related
I am trying to get in touch with Gaussian Process Classification and try to reproduce the example from https://docs.gpytorch.ai/en/stable/examples/01_Exact_GPs/GP_Regression_on_Classification_Labels.html
Following their code, I want to import the Dirichlet Classification Likelihood by
from gpytorch.likelihoods import DirichletClassificationLikelihood
However, this seems not to work, and I get the Error:
ImportError: cannot import name 'DirichletClassificationLikelihood'
from 'gpytorch.likelihoods' (/Library/Frameworks/Python.framework/Versions/3.8/
lib/python3.8/site-packages/gpytorch/likelihoods/__init__.py)
also other likelihoods as FixedNoiseGaussianLikelihood does not work.
I tried to reinstall GPyTorch in Conda, which did not help.
but importing i.e GaussianLikelihood works without problems. Did somebody had similar problems, or knows how to solve this Error?
EDIT: It only does not work for Jupyter Notebook.
Best
Solved it.
The paths of Jupyter Notebook did not include the new updated library. After updating paths to the wanted folder by
import sys
sys.paths.append("....")
it worked nice.
Best
Pycharm is giving me a
AttributeError: module 'http' has no attribute 'client'
when trying to load in pandas for a specific file. Strangely I only get this error if I also have the following import:
from sklearn import svm
pandas is with the Anaconda package suite, and runs/loads without the sklearn module, and in the console.
Python 3.7, Github extension, anaconda suite. I have tried reinstall pandas and sklearn to no avail. I have tried reordering my file structure to avoid python path issues.
python
import pandas
from sklearn import svm
I expect the code to compile as there are no noticeable syntax errors and even with the rest of the code commented out this still happens.
edit: it compiles when run in the console, so there appears to be an issue with the python path. Is there a way to investigate this more closely or directly control the python path? Also it compiles when I run with
import sklearn
but does not with
from sklearn import svm
if that helps narrow down the issue at all...
The problem appears to be that my file is named ssl.py I don't know if there's another file called that which was cauing path issues but it seems to be fixed now...
I keep getting this error whenever I try running this code, if I can get some insight in what is going on that would be a great help, since I'm pretty new to this coding environment I would really appreciate some help. The code is this:
File "C:\Users\user\Desktop\Python\pythonsimulation.py", line 6, in
from scipy import *
File "C:\Python34\lib\site-packages\scipy__init__.py", line 61, in
from numpy._distributor_init import NUMPY_MKL # requires numpy+mkl
ImportError: cannot import name 'NUMPY_MKL'
Am I missing some package or module that python requires in order to run the code?
Reason:
This error indicates that numpy is missing NUMPY_MKL. This usually happens when you have installed scipy from .whl (Pre-compiled File). To resolve this.
Solution:
Download numpy+MKL wheel(.whl) from following link and install using pip.
http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
If you are using Jupyter, try restarting the kernel. please click Restart in Kernel menu.
Actually, there is no problem. Just need to restart the Jupyter and you will see it is working well.
trying to import scipy.interpolate but it can’t import _fblas.pyd. It keeps throwing the following error
File "C:\cygwin64\lib\python2.7\site-packages\scipy/linalg/blas.py", line 155, in <module>
from scipy.linalg import _fblas
ImportError: cannot import name _fblas
My online research suggested that this is because I had the wrong version of numpy installed, and I need to install numpy+mkl. So I uninstalled the version I had and pip installed numpy 1.10.4, which includes mkl.
This did not fix the original problem with _flbas.pyd.
I would reinstall scipy but I can't remember where I got the version I have, and when I pip install scipy 0.17.1.tar.gz it throws an error saying that it has no blas resources, which are necessary. I've also tried to download it from here: https://github.com/scipy/scipy/releases, but they don't include _fblas.pyd in the first place.
I’m not sure where to go from here. I'm not even entirely sure why it won't import the _fblas.pyd file.
This looks like you tried to manually comply to your needed packages. Even though I take my hat off at your effort, keep in mind that this is not an simple task at all.
I might also add that this kind of work is not meant for a developer ("the person who writes the code"), but a full time maintainer. Specially with your particular Cygwin environment
So, what can you do? Alternatively, you can use one of Continuum's mkl-ready python-and-many-tools-including-mkl+scipy distribution or Enthought's Canopy. Hopefully, this will avoid you lots of hours of staring at the screen wondering what's wrong
I don't have a lot of programming experience, so please try to keep answers relatively noob-friendly! :) Basically, I have a Python...library, I guess? or module? that I need to run in Spyder through Anaconda. This seems to be a very obscure module called PySPM, used for analyzing scanning probe microscopy data, that I received from a colleague my lab collaborates with. When I try to run a piece of software which uses this module, it gives this error:
ImportError: No module named 'PySPM.io'
The code itself which triggers this reads as follows:
from os import path
from PySPM.io.Translators.Utils import uiGetFile
from PySPM.io.Translators.BEPSndfTranslator import BEPSndfTranslator
from PySPM.io.Translators.BEodfTranslator import BEodfTranslator
from PySPM.analysis.BESHOFitter import BESHOFitter
The first line that says from PySPM.io.Translators.Utils import uiGetFile is what's triggering the error. I'm really stuck scratching my head here. What's going on and how can I solve it?
Pycroscopy is the (thoroughly) reorganized version of PySPM.
#Martensite try:
$ pip install pycroscopy