Python Error: can't install scipy.optimize.brentq - python

I am using the Python module called PRECESSION to model the inspiral of binary black holes. As it states in the linked paper, to use the function "Sb_limits" requires the use of scipy.optimize.brentq
However, it seems that my system is not able to download/install scipy.optimize.brentq for some reason(s) that I do not understand. Specifically, as the attached image shows, I receive these errors in the cmd prompt:
ERROR: Could not find a version that satisfies the requirement
scipy.optimize.brentq (from versions: none)
ERROR: No matching distribution found for scipy.optimize.brentq
No one appears to have posted this issue already, although I'm probably missing something basic. I'm not sure if I can just create the scipy.optimize.brentq module myself using the source code here (seems like I'd be trying too hard!)??
My problem seems deeper than just "you need to install scipy" ............
Since I have already installed it and brentq is nowhere to be found:

You just need to install scipy:
pip install scipy
then you can call brentq method inside your code:
import scipy.optimze as so
so.brentq(...arg)
Description
scipy is a package that aims to help scientist to use python for their research, it has some subpackages that each one does special things. for example optimize designed for optimizations. linalg do some algebra.
if you want to use sub packages in python you have to import them explicitly. so the following code doesn't work.
import scipy
scipy.optimize.brentq

Related

HDBSCAN: ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject

I try to inititialize HDBSCAN for clustering in JupytherLab. I use Python 3.7.6..
import numpy as np
import pandas as pd
from sklearn.datasets import load_digits
from sklearn.manifold import TSNE
import hdbscan
There always always appears the same error (see headline) and until now I do not know, from what exactly it comes from.
I have looked in several post after solutions, but no solution has helped me until yet.
For example:
uninstalled and installed numpy.
installed numpy >= 1.20.0
tried lines like pip install package --no-cache-dir --no-binary :all:
tried following package version combination: hdbscan=0.8.19, matplotlib=3.2.2, numpy=1.15.4, pandas=0.23.4, scikit-learn=0.20.1, scipy=1.1.0, tensorflow=1.13.1.
I have also tried to install packages like tensorboard, but it did not helped. Everything is installed via the Terminal and with pip.
I start to think, that the problem might be deeper - but maybe I overlooked something important.
Can somebody help me to find the bug, please?
Best regards
Philipp
I guess you've probably seen this very long HDBSCAN GitHub issue where there still doesn't seem to be a clear solution. Unfortunately it seems to affect different systems in weird ways and there is a huge list of possible solutions and things that worked for other people (personally, just reinstalling numpy worked for me when I had a similar problem last week.)
The fact that you can try so many things and still have it not work seems suspicious. Maybe something else about your Python install or the way you're trying them is affecting the solutions? For instance, is JupyterLab definitely using the same Python environment that you're trying these solutions on? (You could test this by uninstalling HDBSCAN and seeing if the error changes instead to "package not found.")
Other than the many solutions in the GitHub issue (which it sounds like you've already tried), I really don't think there's much else you can try other than freshly reinstalling Python. Something about NumPy 1.20 and a change to the C API is causing this issue and it could be that something is lurking in your install every time you try these solutions.
Alternatively, you could make a new Python install/environment with a tool like pyenv or anaconda so that it doesn't break your existing install, and you can try and install just the bare minimum on this new install (i.e. just HDBSCAN.)
Upgrading the numpy library solved the problem.
My numpy version is 1.22.0 and sklearn version is 0.24.1.
you should also look here: ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject

error using trimesh library on python - " no graph engine available "

I was wondering if you have used the library "trimesh" in python. It looks quite useful, but right now im having some trouble with the method "Trimesh.spli()" on the last line of the code attached. the code was working fine up to that line, which is suppose to return a list of trimesh objects.
However, when I try to run this code, I get the error ImportError: no graph engines available!
Do you know how can I set up a graph engine? or if there is any turnaround this issue?
Thanks for your support,
Regards
import numpy as np
import trimesh
# Load the stl files into the script
mesh = trimesh.load('Path_to_STL_file')
mesh2 = trimesh.load('Path_to_raw_material_in_STL')
# Confirm both files are closed
assert mesh.is_watertight
assert mesh2.is_watertight
#Boolean operation
mesh3 = trimesh.Trimesh.difference(mesh2,mesh)
list_mesh = trimesh.Trimesh.split(mesh3)
I found the issue. The library does not install all dependancies unless you ask for it. Usually, it only requires numpy.
One option to install most of the dependancies is:
pip install trimesh[easy]
or, if that doesn't solve it, you could use:
pip install trimesh[all]
You need to also install either scipy or networkx to satisfy the graph engine dependency. There's a comment in the source code that networkx is 5-10 times slower than scipy so it's probably best to install scipy. If you're using pip then it's
pip install scipy
or if you're using conda:
conda install scipy

can't import pyd file from scipy

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

Issue downloading Python Panda's module

I am a programming novice, so apologize in advance if I'm asking a dumb question or perpetrating some site etiquette violation. I have tried very hard to research the answer to my question on an issue that seems to be very common, but none of the proposed solutions have worked, so am looking for some help as I just don't know what to try next.
I'm trying to import Panda from iPython onto Windows 8. I have version 2.7 of Python and have successfully downloaded Numpy. Given the suggestions on this site, I have downloaded all the file that I think Panda is dependent on (pytx, dateutil, setuptools), but it still didn't work: the error message includes:
Import Error Traceback (most recent call)
<ipython-input-2-d6ac987968b6> in <module>()
try
from.import hashtable, tslib, lib
except exception: # pragma: no cover
import datetime
- C: \Python27\lib\site-packages\pandas\__init__.py in <module>():
Import Error: No module named six
Out of desperation, I also deleted all previous version of pandas and loaded Aneconda, thinking from previous responses that might help capture all required modules including Pandas, but the same error keeps coming up.
Any help would be much appreciated, and don't worry about pointing out the obvious (since it's clearly not obvious to me.)
The easiest way to get modules up and running on Windows is to use Christoph Gohlke's Python Extension Packages for Windows repository. It includes installers for a ton of (mainly scientific-related) modules, including pandas, matplotlib, six, etc. Since many modules included compiled extensions, installing using pip doesn't always work if the package maintainer hasn't published a binary for your package of interest. Gohlke's packages include everything already pre-compiled, you just need to choose the version and bit-ness of Python, and download the .exe files.

error on importing pyIpopt

I'm trying to install and configure pyIpopt. Ipopt is already installed and the examples run fine.
From the shell, when I do import pyIpopt, I get the error:
ImportError: /***PATH***/libipopt.so.1: undefined symbol: MPI_Init
The FAQ section of the pyIpopt git project has this to offer for these kinds of errors:
Do a Google search to find the library file, and add
-lWhateverLibrary in the makefile of pyipopt.
I've googled and found this: http://www.mcs.anl.gov/research/projects/mpi/www/www3/MPI_Init.html.
I don't know how to get the library or add it to the makefile... Any assistance would be much appreciated!
Just had a similar problem on ubuntu.
Using libmumps-seq worked for me:
installed libmumps-seq-4.9.2 (just with apt-get, along side the ordinary libmumps)
in setup.py changed in the libraries list argument 'coinmumps' to 'dmumps_seq-4.9.2'
rebuilt and installed.
If I understand it correctly, the default mumps is distributed (using MPI lib which can be a world of pain), and all i needed is the sequential one, which mumps-seq provides.

Categories