scipy ImportError: dlopen no suitable image found in Python 3 - scipy

I have python 3.6, Mac OS X El Capitan.
I installed scipy by pip install scipy. But when I import scipy, I get the following error:
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/scipy/init.py in ()
116 del _NumpyVersion
117
--> 118 from scipy._lib._ccallback import LowLevelCallable
119
120 from scipy._lib._testutils import PytestTester
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/scipy/_lib/_ccallback.py in ()
----> 1 from . import _ccallback_c
2
3 import ctypes
4
5 PyCFuncPtr = ctypes.CFUNCTYPE(ctypes.c_void_p).bases[0]
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/scipy/_lib/_ccallback_c.cpython-36m-darwin.so, 2): no suitable image found. Did find:
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/scipy/_lib/_ccallback_c.cpython-36m-darwin.so: mach-o, but wrong architecture
I don't get this error in Python2.

Looks like I am the only one on earth to have this issue. Fortunately, I got it to work with endless attempts. In case someone in the future gets the same error, you can try this:python -m pip install scipy. I have no idea why pip install scipy doesn't work.

What I did find on MacOS 10.14.2 is that I had installed Scipy 1.1. After executing python -m pip install scipy I got Scipy 1.2 and get rid of "ImportError: dlopen".

Related

Cannot import name 'rank_zero_only' from 'pytorch_lightning.utilities.distributed'

I am using VQGAN+CLIP_(Zooming)_(z+quantize_method_with_addons).ipynb Google Repository and when I click the cell "Loading of libraries and definitions"
It sent an error :
ImportError Traceback (most recent call last)
<ipython-input-6-fe8fafeed45d> in <module>
24 from omegaconf import OmegaConf
25 from PIL import Image
---> 26 from taming.models import cond_transformer, vqgan
27 import torch
28 from torch import nn, optim
1 frames
/content/taming-transformers/main.py in <module>
10 from pytorch_lightning.trainer import Trainer
11 from pytorch_lightning.callbacks import ModelCheckpoint, Callback, LearningRateMonitor
---> 12 from pytorch_lightning.utilities.distributed import rank_zero_only
13
14 from taming.data.utils import custom_collate
ImportError: cannot import name 'rank_zero_only' from 'pytorch_lightning.utilities.distributed' (/usr/local/lib/python3.7/dist-packages/pytorch_lightning/utilities/distributed.py)
I don't know how to solde this problem. I don't know how to manually install Pytorch as it said "NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below."
Thank you in advance if you have the solution.
Inès
I triad !pip install but I may not really know where to put this cell/line of code
pytorch_lightning has recently released a new version which will throw this error (version 1.8.0.post1 released on November 2nd 2022).
https://pypi.org/project/pytorch-lightning/#history
Just install an older version of pytorch_lightning and it will work.
In my system, I ran "pip install pytorch-lightning==1.6.5", higher versions may work as well, you can check them out by clicking on the link provided above and then clicking on release history.
Finally, after long research, I found the solution for it, try to run it, you will face an issue with CLIP module, once you resolve python issue as well, so for that follow the second code.
conda install pytorch-lightning -c conda-forge
Once you clone it, try to follow below command
Step:1 cd CLIP
Step2: python setup.py
after that,
type: cd..
Once you do that, you will be redirected to previous directory named "VQGAN-CLIP"
and finally, run the following command:
python generate.py -p "A painting of an apple in a fruit bowl"
Once it is done, then run your generate python file, It will work fine.
use #vishisht-rao solution to downgrade the package version of pytorch-lightning to 1.7.7; this step by itself did not solve the problem for me.
pip install pytorch-lightning==1.6.5
run pip list|grep lightning to find the installed version of lightning-utilities. Mine was lightning-utilities==0.4.2
Downgrade the package version of lightning-utilities to 0.4.0
pip install lightning-utilities==0.4.0
Downgrading the package versions of both pytorch-lightning and lightning-utilities solved the problem for me.

Got cluster not defined when trying to run cluster.vq.vq() in Scipy lib

I am trying to learn anomaly detection by following :
https://github.com/sayakpaul/FloydHub-Anomaly-Detection-Blog/blob/master/FloydHub%20Anomaly%20Detection%20Blog.ipynb
I installed necessary libraries using:
python -m pip install --user numpy scipy matplotlib ipython jupyter pandas sympy nose
cluster.vq.vq() is included in these libraries. However i am getting name error :
NameError: name 'cluster' is not defined
Any help is appreciated.
Now i solved my own question,
You just need to import:
from scipy.cluster.vq import vq
and instead of cluster.vq.vq(), vq() is enough

Import error with GeoPandas in Jupyter Notebook on OSX10.11.6

When importing geopandas into my Jupyter Notebook, it throws the following error.
ImportError: dlopen(/opt/anaconda3/lib/python3.7/site-packages/pyproj/_datadir.cpython-37m-darwin.so, 2): Symbol not found: _clock_gettime
Referenced from: /opt/anaconda3/lib/python3.7/site-packages/pyproj/.dylibs/liblzma.5.dylib (which was built for Mac OS X 10.13)
Expected in: /usr/lib/libSystem.B.dylib
in /opt/anaconda3/lib/python3.7/site-packages/pyproj/.dylibs/liblzma.5.dylib
I have installed geopandas through a pip install from the command line.
My machine runs OSX 10.11.6 (and can't upgrade).
I have also tried uninstalling the pip install and installing through conda instead. Importing geopandas in my JN then throws the following error:
ImportError: cannot import name 'Iterable' from 'geopandas._compat' (/opt/anaconda3/lib/python3.7/site-packages/geopandas/_compat.py)
Problem solved by restarting Jupyter Notebooks.

Upgrading Scipy on IronPython

I'm kind of new to Scipy and IronPython, so please excuse any dummy question I might be asking.
Anyway, I'm trying to upgrade my scipy version to >1.1 on my IronPython 2.7.5 (OS is Windows 7 64bit) but I am not really sure how to do it.
My current scipy version is 1.0.0.
I've tried to run from command prompt:
ipy -X:Frames -m pip install --upgrade scipy
But I'm getting this:
Downloading/unpacking scipy
C:\Program Files (x86)\IronPython 2.7\lib\site-packages\pip\_vendor\requests\packages\urllib3\connectionpool.py:1: DeprecationWarning: object.__new__() takes no para
meters
# urllib3/connectionpool.py
Cannot fetch index base URL https://pypi.python.org/simple/
Could not find any downloads that satisfy the requirement scipy
Cleaning up...
No distributions at all found for scipy
Any help on how to get it to work will be appreciated. Alternatively, if there are other ways to easily install newer compiled version of scipy on IronPython env, it's also OK - I just need to know.

ImportError: No module named 'bson.objectid' [duplicate]

I have currently django-mongodb-engine 0.4.0 version installed on my Mac OS X 10.6.8 and weirdly encountered an interesting error while importing the 'compiler' module:
>> from django_mongodb_engine import compiler
and I got the following error:
ImportError Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django_extensions/management/commands/shell_plus.pyc in <module>()
----> 1 from django_mongodb_engine import compiler
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django_mongodb_engine/compiler.pyc in <module>()
15 from pymongo.errors import PyMongoError
16 from pymongo import ASCENDING, DESCENDING
---> 17 from pymongo.objectid import ObjectId, InvalidId
18
19 from djangotoolbox.db.basecompiler import NonrelQuery, NonrelCompiler, \
ImportError: No module named objectid
I installed the package via pip command and all the dependencies like pymongo, djangotoolbox have been installed along with it. The pip command I'd used is this:
>> sudo env ARCHFLAGS='-arch i386 -arch x86_64' pip install --upgrade django-mongodb-engine
The current versions of the related packages are:
>> pip freeze | grep mongo
django-mongodb-engine==0.4.0
pymongo==2.2
I suspect the django_mongodb_engine package is broken because ObjectId is not imported inside pymongo anymore. Instead, it belongs to bson module.
What are your suggestions to fix this problem? Should I clone the django-mongodb-engine project and fix on github?
I've ran into something similar, for me the problem was this line:
from pymongo.objectid import ObjectId
The call seems to work in versions of PyMongo < 2.2
In pymongo 2.2 the call to import objectid is:
from bson.objectid import ObjectId
Looks like they're already aware (see this pull request), but no one's created a pull request against the develop branch yet. You could try fixing that and submit a new pull request.
I tried to install bson with pip directly. Uninstall, and install pymongo instead and the error didnt reappear.
I'm on Python3 (in 2017) and found that the following works:
from pymongo import MongoClient
from bson import ObjectId