ImportError when installing NumPy for Python 2.7 - python

EDIT: after reading this http://projects.scipy.org/numpy/ticket/1322 it seems that the NumPy version I am using doesn't work with Mac OS 10.5.x. Does anyone have access to a version of NumPy that works with Mac OS 10.5? I can't get it to compile either.
Original post ...
I am trying to use NumPy, but I'm having difficulty installing it. I'm using the installer that is available on sourceforge.
NumPy v1.5.0 (Py2.7)
Python 2.7
Mac OS 10.5.8 (PPC)
After running the installer (all I did was double-click the .pkg and follow the instructions), I try to import it ...
>>> import numpy
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import numpy
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/nump/__init__.py", line 153, in <module>
import random
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/random/__init__.py", line 87, in <module>
from mtrand import *
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/random/mtrand.so, 2): Symbol not found: _fopen$UNIX2003
Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/random/mtrand.so
Expected in: /usr/lib/libSystem.B.dylib
Does anyone have experience with this or have advice on how to fix it?
Thanks!

You can find discussion about current problems with Mac OS on the numpy mailing list, and I would recommend to discuss installation problems there, since that's were the developers are that try to fix the problems.
for example
http://groups.google.com/group/numpy/browse_thread/thread/a0ceb45b58feca2b#
and this is OS 10.5 specific
http://groups.google.com/group/numpy/browse_thread/thread/de75279785d56a25/2bfbb96e6d6c0a2e
You could join the effort, since they don't seem to have many OS 10.5 users available for testing.

Related

Problems with NumPy version with Python 3.10

Need help please with fixing the NumPy problem I have. Tried to fix it for 2 days and didn't get far.
I have installed Python 3.10. I am using PyCharm.
When I debug my app I keep on getting the following error:
{Traceback (most recent call last):\r\n File \"C:\\Users\\Administrator\\PycharmProjects\\PaySlip_New\\main.py\", line 2, in <module>\r\n
from src.common.ParserFactory import ParserFactory\r\n
File \"C:\\Users\\Administrator\\PycharmProjects\\PaySlip_New\\src\\common\\ParserFactory.py\", line 1, in <module>\r\n
from src.parsers.regular_parser import Parser\r\n File \"C:\\Users\\Administrator\\PycharmProjects\\PaySlip_New\\src\\parsers\\regular_parser.py\", line 1, in <module>\r\n from src.common.ParserMain import ParserMain\r\n File \"C:\\Users\\Administrator\\PycharmProjects\\PaySlip_New\\src\\common\\ParserMain.py\", line 1, in <module>\r\n
import pandas as pd\r\n File \"C:\\Users\\Administrator\\PycharmProjects\\PaySlip_New\\venv\\lib\\site-packages\\pandas\\__init__.py\",
line 16, in <module>\r\n
raise ImportError(\r\nImportError: Unable to import required dependencies:\r\nnumpy: \r\n\r\nIMPORTANT:
PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!\r\n\r\nImporting the numpy C-extensions failed.
This error can happen for\r\nmany reasons, often due to issues with your setup or how NumPy was\r\ninstalled.\r\n\r\nWe
have compiled some common reasons and troubleshooting tips at:\r\n\r\n
https://numpy.org/devdocs/user/troubleshooting-importerror.html\r\n\r\nPlease note and check the following:\r\n\r\n * T
he Python version is: Python3.10 from \"C:\\Users\\Administrator\\PycharmProjects\\PaySlip_New\\venv\\Scripts\\python.exe\"\r\n
* The NumPy version is: \"1.19.4\"\r\n\r\nand make sure that they are the versions you expect.\r\nPlease carefully study the documentation
linked above for further help.\r\n\r\nOriginal error was: No module named 'numpy.core._multiarray_umath'\r\n\r\n}
When I run cmd version I get this:
C:\Users\Administrator>pip3 show numpy
Name: numpy
Version: 1.21.4
pypvenv.cfg
home = C:\Users\Administrator\AppData\Local\Programs\Python\Python310
implementation = CPython
version_info = 3.10.6.final.0
virtualenv = 20.13.0
Please help me. Thank you!
The error message says "Numpy version is 1.19.4", but you expect it to be version 1.21.4. Your pandas version seems to be incompatible with numpy 1.19.4.

ImportError: cannot import name get_ast_names error on lmfit

I have recently updated to Ubuntu 18.04.1 LTS. After that I tried to run some of my python codes and I got an error related to the lmfit package, here's the code:
import scipy
from asteval import get_ast_names
import lmfit
(I have explicitly added the scipy and asteval modules to check python was finding them porperly)
I obtained this error:
Traceback (most recent call last):
File "/home/maurizio/Documents/Python/Programmini/PhD/TEAS/Test.py", line 3, in <module>
import lmfit
File "/home/maurizio/.local/lib/python2.7/site-packages/lmfit/__init__.py", line 42, in <module>
from .confidence import conf_interval, conf_interval2d
File "/home/maurizio/.local/lib/python2.7/site-packages/lmfit/confidence.py", line 12, in <module>
from .minimizer import MinimizerException
File "/home/maurizio/.local/lib/python2.7/site-packages/lmfit/minimizer.py", line 35, in <module>
from .parameter import Parameter, Parameters
File "/home/maurizio/.local/lib/python2.7/site-packages/lmfit/parameter.py", line 8, in <module>
from asteval import Interpreter, get_ast_names, valid_symbol_name
ImportError: cannot import name get_ast_names
which basically states that lmfit cannot find the function get_ast_names from asteval, although the python interpreter doesn't complain when I try to import it so it should be properly installed.
I have found this question with a similar problem and the guy in the comments claims he solved it by reinstalling it with pip3, so I tried to compile it with python3 and there's no problem so the issue concerns only python 2
Any help?
I believe you must have conflicting versions of lmfit and asteval. This should have been automatically noticed (and ideally resolved) when installing lmfit, but something there appears to have gone wrong. For the latest releases, you should get
>>> import asteval
>>> asteval.__version__
0.9.12
>>> import lmfit
>>> lmfit.__version__
0.9.11
Depending on how you installed these, you may need to check for and remove older versions of asteval in your $HOME/.local/lib/python2.7/site-packages/ folder and re-do pip install asteval.

ImportError: DLL load failed when importing Numpy installed in conda virtual environment

In Windows, I created a Conda virtual environment with the command
conda create -n test python=2.7 pandas scipy matplotlib numpy
Once it is created, I activated the virtual environment and went into a python interpreter. When trying to import numpy, I get the following error:
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Anaconda3\envs\test\lib\site-packages\numpy\__init__.py", line 180, in <module>
from . import add_newdocs
File "C:\Anaconda3\envs\test\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\Anaconda3\envs\test\lib\site-packages\numpy\lib\__init__.py", line 8,
in <module>
from .type_check import *
File "C:\Anaconda3\envs\test\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "C:\Anaconda3\envs\test\lib\site-packages\numpy\core\__init__.py", line 14, in <module>
from . import multiarray
ImportError: DLL load failed: The specified module could not be found.
Any ideas what is going on here? Thanks!
Uninstall and install numpy again.
pip uninstall numpy
pip install numpy
Then try import again, it should work. That is what I did
Unlike #Rafael, for me, libiomp5md.dll wasn't the issue. I installed Dependency Walker to investigate what was going on. Even though the dll versions were different, but Dependency Walker said it was okay.
What was wrong though, was that mkl_intel_thread.dll had warnings (red icon). If you're using Win 8++, ignore the api-win and ext-ms issues as Dependency Walker wasn't updated for new Windows versions and doesn't recognise Windows new APIs.
My solution is to copy all mkl_*.dlls from the former to the latter:
\Anaconda2\Library\bin
\Anaconda2\Lib\site-packages\numpy\core
I was able to import numpy and sklearn after that.
It seems the proper way to fix this is to do:
conda install msvc_runtime
If you are in a virtual environment, add this package there.
For my case, I have also the import numpy DLL error in anaconda3, and Decrayer (Nov 28) provided the best solution: I had the same error except for Anaconda3: just added the path \Anaconda3\Library\bin to your Windows 10 path variable and then it worked.
I have been trying to install anaconda3.7.1 or 3.7.0 without luck, going to full length of restarting the PC after the key steps to make sure the DLL is no longer in use in memory. Ultimately, thanks to decrayer, now numpy works for me!
For me this was solved by adding the following paths to my system path variable.
C:\Users\UserName\Anaconda3\
C:\Users\UserName\Anaconda3\bin
C:\Users\UserName\Anaconda3\Scripts
C:\Users\UserName\Anaconda3\Library\mingw-w64\bin (not strictly necessary)
C:\Users\UserName\Anaconda3\Library\bin
Before adding them explicitly in the system path variable, you can perform a test by adding these paths temporarily:
base_path = r"C:\Users\UserName\Anaconda3"
path = os.pathsep.join([os.path.join(base_path, i) for i in [r"", r"bin", r"Scripts", r"Library\mingw-w64\bin", r"Library\bin"]])
os.environ["PATH"]+=os.pathsep+path
Thanks to this post on PyCharm support.
For the record, I had the same error here (Python 3.5 64-bit on Windows 10), and this page helped me find the solution. The problem was a conflict with libiomp5md.dll, which existed on two locations:
C:\Windows\System32\libiomp5md.dll
C:\Anaconda3\Library\bin\libiomp5md.dll
Python was trying to use the version in System32 folder, which was an old version. I removed it (renamed) and now it uses the correct version, on Anaconda3 folder, and now I can import numpy without the import error.

scipy.optimize dll load failure on Windows 8

I am attempting to import scipy.optimize using Python 3.3.1 on Windows 8. I am using scipy-0.12.0. When I attempt to import, Python returns the following error:
>>> import scipy.optimize
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python33\lib\site-packages\scipy\optimize\__init__.py", line 146, in
<module>
from .optimize import *
File "C:\Python33\lib\site-packages\scipy\optimize\optimize.py", line 34, in <
module>
from .linesearch import \
File "C:\Python33\lib\site-packages\scipy\optimize\linesearch.py", line 16, in
<module>
from scipy.optimize import minpack2
ImportError: DLL load failed: The specified module could not be found.
I believe this is an operating system error because importing scipy.optimize succeeds when using the same version of Python and scipy on a Windows 7 machine.
I would greatly appreciate any assistance.
Thanks.
It may be a problem with using an incompatible version of Numpy. We solved this problem on a computer at work by using a Numpy-MKL build from Christoph Gohlke's website. This solved our problems on Windows 8 computers, because the builds for Scipy from his website require the Numpy MKL build.
I really encourage you to Install SciPy and NumPy with one these packages:
Python(x,y)
Anaconda
Enthought
Other wise you will end up with all the strange error because these packages mainly based on C libraries that they need to be compiled and usually standard Windows installation doesn't have the right compiler.

rpy + matplotlib + arcpy

I am trying to use ryp with my arcpy scripts but I have the following error:
import rpy2.robjects as robjects Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module> import rpy2.robjects as robjects
File "C:\Python26\ArcGIS10.0\lib\site-packages\rpy2\robjects\__init__.py", line 12, in <module> import rpy2.rinterface as rinterface
File "C:\Python26\ArcGIS10.0\lib\site-packages\rpy2\rinterface\__init__.py", line 39, in <module> import win32api
ImportError: No module named win32api
This error comes even after the installation of the pywin32 for my version of python.
I've noticed that this seems to be a common error that is usually solved with the installation of pywin32.
I also have a problem with the matplotlib installation, every time i try to use it (import matplotlib.pyplot as plt), python crashes...
Versions:
Python 2.6.6
matplotlib installation: matplotlib-1.1.0.win32-py2.6.exe
You will need to run these scripts with PROPER Python. It seems to me that the ArcPy distribution does not include the win32api module (It also does not exist from example in Python on Mac or Linux).
I would install PythonXY which includes R bindings, and see if your scripts run there. If they run there, then I (guess) I am correct, and ArcPy does not include these modules.
A nice BONUS of PythonXY is it's an excellent Python IDE (Spyder), but the real bonus is what the commenter above me said:
different compiler versions can cause hell of a lot of Problems.
So, in PythonXY you get a whole bundle compiled with the same compiler.
Let us know if these made your RPy script run.

Categories

Resources