Importing numpy fails - python

I originally installed the anaconda distribution of python and have been coding primarily in Spyder. Recently I tried to install the Chaco visualization library and had a lot of trouble getting it to work using pip install - so instead I installed the Unthought Tool Suite which comes with Chaco. This means I now have two python distributions, but I'm not using virtualenv.
I get this error when running any code in Spyder using numpy:
ImportError:
dlopen(/Users/snoran/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-
packages/numpy/linalg/lapack_lite.so, 2): Library not loaded:
#rpath/lib/libmkl_intel_lp64.dylib Referenced from:
/Users/snoran/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-
packages/numpy/linalg/lapack_lite.so Reason: image not found
When importing bumpy throguh the IPython console, I get:
ImportError: cannot import name scimath
Does anyone have any suggestions on how to fix this?
I am using Mac OS X

Related

Python Error 99 while integrating Amibroker with Python

I am trying to integrate Amibroker 6.41 (64-bit) with Python. Currently, I have Python 3.11.1 (64-bit) stand-alone installed along with NumPy, and pandas installed using pip in the python library.
I have installed AmiPy.dll into the Amibroker plugin folder and Amibroker acknowledged its presence.
Need your advice on the following error received while trying to set up cointegration afl using python.
Error 99. Error occurred during Python execution: *ModuleNotFoundError: No Module named '_ctypes' *callback:
It seems to me that it is unable to import the following:
from ctypes._endian import BigEndianStructure, LittleEndianStructure
from ctypes._endian import BigEndianUnion, LittleEndianUnion
On further investigation, it seems that somehow my latest Python 3.11.1 doesn't have ctypes installed. Hence the AmiPy Dll is unable to import the above files.
Unable to decide what should be my next step to resolve this issue.
Finally solved the issue by uninstalling Python 3.11.1 and installing Python 3.10.8 as Python 3.11.1 is broken. The issue is highlighted in the bug report on GitHub (link given below)
So suggest all not to install or use Python version 3.11.1 due to DLLs not being added to sys.path in embedded startup on Windows.
[[1]: https://github.com/python/cpython/issues/100320][1]

matplotlib.pyplot giving error 'ImportError: No module named Tkinter' on python 2.7

I'm using a remote machine for computation and data analysis. I don't have sudo access in this machine, for data analysis purposes I want to use python libraries such as vtk etc since pip is not installed in this machine, I set up a 'virtual-environment' and install VTK there,
I used the method explained here (https://stackoverflow.com/a/13958308/10755782). Then I could install vtk in the virtual environment using pip.
But now the problem is that I can't import matplotlib.pyplot, it is giving me the error
ImportError: No module named Tkinter.
This error is strange because matplotlib.pyplot works in this particular system outside my virtual-environment. There are a few workarounds to start using matplotlib.pyplot without tkinter such as this (https://stackoverflow.com/a/49988926/10755782), but this is not helpfull in my case as this machine is remote-accessed and I need 'tkinter' to view the graphs on my screen.
I tried installing 'tkinter' inside my virtual-env, but I could not ( since we can't install 'tkinter' with pip and I don't have sudo access).
As I could not find any immediate solution to this problem anywhere I tried to fix this myself and I did the following,
inside my virtual environment, the version of matplotlib was 2.2.4 and outside it was 1.2.0 ( which is working fine). So I downgraded the version of matplotlib inside my virtual environment to 1.2.0
pip install 'matplotlib==1.2.0' --force-reinstall
now I have the same version of matplotlib inside and outside the virtual env. But now, when I try import matplotlilb.pyplot as plt I'm getting the error
ImportError: /b/home/ipcms/rcheenik/Python_virt-env/python2.7/my_new_env/lib/python2.7/site-
packages/matplotlib/_cntr.so: undefined symbol: _intel_fast_memset
Is there any way to fix this ^^ error? any of these following will be able to help me.
without OR is there any way to install tkinter without sudo ? or inside the 'virtual-environment' ?
OR is there any alternatives to matplotlib.pyplot which works without 'tkinter' and still display graphs remotely? ( not favourable, as I have to rewrite the entire code )
Thanks in advance for the help.
I found this answer to a similar question however, which I believe would solve your issue.
https://stackoverflow.com/a/49988926/8775307
It imports matplotlib.pyplot without tkinter. I don't know if all the features are actually included though, so you'll have to test and let us know :).
You could always write to the administrator and request Tkinter - it's a widely used and useful package, so they might be willing to include it.

why doesn't python 3.6.1 recognize numpy or pil or skimage after they have been successfully installed

I am getting these errors trying to run a python3 program in itelliJ IDEA on a mac.
import numpy as np
ModuleNotFoundError: No module named 'numpy'
from PIL import Image, ImageChops
ModuleNotFoundError: No module named 'PIL'
from skimage.feature import match_template # requires numpy, scipy, and six
ModuleNotFoundError: No module named 'skimage'
All of these modules have been successfully installed using pip3. I have confirmed the installs using IDLE. Clearly, it seems, there is more to it than simply installing, but I don't know what it is.
I cannot find anything that addresses concerns on python.org. They, in fact, refer me to Stackoverflow. The closest I found here dealt with numpy and python2.7 on mac. There are no responses to that one.
Look in the Preferences for the Project Interpreter setting, and make sure it's pointing to the right python version.
Secondly, since you're already using and IDE use PyCharm. It's IntelliJ's python specific IDE, and it'll have better documentation on python specific technical problems.

ImportError for NumPy/SciPy

I am trying to run some code that requires importing NumPy and SciPy (I'm using Python 3.4), but I keep getting the following message (my OS is Windows):
import numpy as np # used for linear algebra
ImportError: No module named 'numpy'
I have already downloaded NumPy but I don't know how to set it up correctly. Is there any way to fix this? I've been having this error for a while already.
Update: I found the solution. Apparently I had already downloaded both Anaconda (a distribution of Python) and Python, so I deleted both of them and installed back Anaconda, rebooted the computer and now everything works perfectly (can use NumPy and SciPy).

PIL Module / Could not initialize images API

I'm running OSX and Python 2.7. The app I have requires the PIL module, which gives me this error when I try to install it.
I've tried several installations but nothing seems to do the trick. How do I get this to work?
WARNING 2012-04-18 18:15:54,222 dev_appserver.py:3394] Could not initialize images API; you are likely missing the Python "PIL" module. ImportError: dlopen(/Library/Python/2.7/site-packages/PIL/_imaging.so, 2): Symbol not found: _jpeg_resync_to_restart
Referenced from: /Library/Python/2.7/site-packages/PIL/_imaging.so
Expected in: flat namespace
The answer to this was uninstalling everything and then using pip install pil.

Categories

Resources