I'm going to preface this by saying that I'm relatively new to Python and so please forgive me if I have difficulty understanding something.
I've recently been trying to install OpenCV on my computer following the "Installing OpenCV from prebuilt binaries" instructions found here:
http://docs.opencv.org/3.1.0/d5/de5/tutorial_py_setup_in_windows.html#gsc.tab=0
I initially tried to install OpenCV by itself, as I already had Python 3.5 and a working version of numpy. However, my attempts to import cv2 failed, and I eventually decided to uninstall Python and follow all the steps listed on the website. However, I now have this error when I try import numpy:
Traceback (most recent call last):
File "C:/PythonProgramming/SLIC/src/SLICAlgorithm.py", line 1, in <module>
import numpy
File "C:\Python27\lib\site-packages\numpy\__init__.py", line 180, in <module>
from . import add_newdocs
File "C:\Python27\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\Python27\lib\site-packages\numpy\lib\__init__.py", line 4, in <module>
from type_check import *
File "C:\Python27\lib\site-packages\numpy\lib\type_check.py", line 8, in <module>
import numpy.core.numeric as _nx
File "C:\Python27\lib\site-packages\numpy\core\__init__.py", line 20, in <module>
import function_base
File "C:\Python27\lib\site-packages\numpy\core\function_base.py", line 6, in <module>
from .numeric import result_type, NaN, shares_memory, MAY_SHARE_BOUNDS, TooHardError
ImportError: cannot import name shares_memory
Process finished with exit code 1
Other people online seem to have no problem with these instructions, or at least not with numpy. What does this error mean, and what can I do to fix it? I have a 64-bit version of Windows 10 and am working in PyCharm. All help you can provide would be much appreciated.
same problem, the following fix worked for me
pip install -I numpy --force-reinstall
Related
I'm new to conda, but I'm sure I have pandas installed in the base environment. I also have selected it as the python interpreter in VSCode. However, when I try to import pandas it throws the following error:
Traceback (most recent call last):
File "/Users/raimundbuehler/Documents/UNIDOCS/Python:Psychopy:RALT/Rando/Randomization.py", line 2, in <module>
import pandas as pd
File "/Users/raimundbuehler/opt/anaconda3/lib/python3.9/site-packages/pandas/__init__.py", line 22, in <module>
from pandas.compat import is_numpy_dev as _is_numpy_dev
File "/Users/raimundbuehler/opt/anaconda3/lib/python3.9/site-packages/pandas/compat/__init__.py", line 15, in <module>
from pandas.compat.numpy import (
File "/Users/raimundbuehler/opt/anaconda3/lib/python3.9/site-packages/pandas/compat/numpy/__init__.py", line 4, in <module>
from pandas.util.version import Version
File "/Users/raimundbuehler/opt/anaconda3/lib/python3.9/site-packages/pandas/util/__init__.py", line 1, in <module>
from pandas.util._decorators import ( # noqa:F401
File "/Users/raimundbuehler/opt/anaconda3/lib/python3.9/site-packages/pandas/util/_decorators.py", line 14, in <module>
from pandas._libs.properties import cache_readonly # noqa:F401
File "/Users/raimundbuehler/opt/anaconda3/lib/python3.9/site-packages/pandas/_libs/__init__.py", line 13, in <module>
from pandas._libs.interval import Interval
ImportError: dlopen(/Users/raimundbuehler/opt/anaconda3/lib/python3.9/site-packages/pandas/_libs/interval.cpython-39-darwin.so, 0x0002): rebase opcodes terminated early at offset 1 of 1800
I'm assuming numpy to be the problem, but updating both numpy and pandas didn't solve it. It may also be because I have Pycharm and pip installed, so it may be messy regarding multiple installations of python and packages... in fact in Pycharm, I can import pandas (using a different interpreter). Any help how to find out if this is indeed the case and how to solve it would be greatly appreciated!
I refer to this issue.
I think the feasible way may still be to unload and reinstall.
I would like to call a python function from C++ and get the return value. I've been able to do that with an easy multiply python function using this website's example code in section 5.3. To compile my program, I would run g++ test.cpp -I/usr/include/python2.7 -lpython2.7. However, the python function I want to run imports numpy. When I try to run my program that is similar to the one on the code example mentioned above, I get an "ImportError: cannot import name _remove_dead_weakref". The full error is here:
Traceback (most recent call last):
File "/home/osboxes/Desktop/test.py", line 1, in <module>
import numpy as np
File "/home/osboxes/.local/lib/python2.7/site-packages/numpy/__init__.py", line 142, in <module>
from . import add_newdocs
File "/home/osboxes/.local/lib/python2.7/site-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/home/osboxes/.local/lib/python2.7/site-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/home/osboxes/.local/lib/python2.7/site-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/home/osboxes/.local/lib/python2.7/site-packages/numpy/core/__init__.py", line 74, in <module>
from numpy.testing.nosetester import _numpy_tester
File "/home/osboxes/.local/lib/python2.7/site-packages/numpy/testing/__init__.py", line 10, in <module>
from unittest import TestCase
File "/home/osboxes/miniconda2/lib/python2.7/unittest/__init__.py", line 64, in <module>
from .main import TestProgram, main
File "/home/osboxes/miniconda2/lib/python2.7/unittest/main.py", line 7, in <module>
from . import loader, runner
File "/home/osboxes/miniconda2/lib/python2.7/unittest/runner.py", line 7, in <module>
from .signals import registerResult
File "/home/osboxes/miniconda2/lib/python2.7/unittest/signals.py", line 2, in <module>
import weakref
File "/home/osboxes/miniconda2/lib/python2.7/weakref.py", line 14, in <module>
from _weakref import (
ImportError: cannot import name _remove_dead_weakref
Some information: Python version is Python 2.7.14 :: Anaconda, Inc. (Is there a difference between python 2.7.14 and my version which has anaconda, inc. at the end?) The python program also runs just fine by itself. Any help would be appreciated. Thanks!
Edit: The path was being all weird with some parts going to my local python and numpy going to miniconda's python. Uninstalling miniconda as it wasn't needed for me fixed it.
This is happening because your environment is mixing two different Python installations. You can see it jump between them here:
File "/home/osboxes/.local/lib/python2.7/site-packages/numpy/testing/__init__.py"
File "/home/osboxes/miniconda2/lib/python2.7/unittest/__init__.py"
So you start out in /home/osboxes/.local/lib/python2.7/site-packages which is the Python installed by some system package manager (or perhaps even explicitly installed from source). But then it jumps to /home/osboxes/miniconda2/lib/python2.7 which is from Conda.
Since it appears you are intending to use Python from Conda, you need to install NumPy using Conda (so it is loaded from miniconda2 and not .local, and build your code using something like -I/home/osboxes/miniconda2/include/python2.7 instead of -I/usr/include/python2.7.
I'm trying to use the Reticulate package to use Python through R. I successfully connected Reticulate to Python 3.6 with Sys.setenv(RETICULATE_PYTHON = "/usr/local/bin/python3"). Then after noticing that my Python 3.6 didn't have Numpy, I used entered pip3 install numpy into the command line and installed it. Now, I am having the following problem with Reticulate when I call py_config():
py_config()
Error in py_run_string_impl(paste0("import sys; sys.path.append('", system.file("python", :
ImportError: cannot import name 'dtype'
Detailed traceback:
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numpy/__init__.py", line 142, in <module>
from . import add_newdocs
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numpy/core/__init__.py", line 35, in <module>
from . import _internal # for freeze programs
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/nump
Uninstalling Numpy fixes the problem, but then I don't have Numpy. :(
Can anyone tell me what's going on and how I can fix it?
I am trying to run some C++ code with embedded Python. Code was working completely fine a couple of weeks ago. The code still compiles, but I am now getting the error
Traceback (most recent call last):
File "./main.py", line 1, in <module>
import numpy as np
File "/usr/local/lib/python2.7/site-packages/numpy/__init__.py", line 142, in <module>
from . import add_newdocs
File "/usr/local/lib/python2.7/site-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/usr/local/lib/python2.7/site-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/usr/local/lib/python2.7/site-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/usr/local/lib/python2.7/site-packages/numpy/core/__init__.py", line 74, in <module>
from numpy.testing.nosetester import _numpy_tester
File "/usr/local/lib/python2.7/site-packages/numpy/testing/__init__.py", line 10, in <module>
from unittest import TestCase
File "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/__init__.py", line 64, in <module>
from .main import TestProgram, main
File "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/main.py", line 7, in <module>
from . import loader, runner
File "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/runner.py", line 7, in <module>
from .signals import registerResult
File "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/signals.py", line 2, in <module>
import weakref
File "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7/weakref.py", line 14, in <module>
from _weakref import (
ImportError: cannot import name _remove_dead_weakref
Since then the only change I have made is to install the macOS Supplemental Update and to upgrade Python from 2.7.13_1 to 2.7.14_2 (using Homebrew). I have changed the relevant linker flags in the makefile, i.e. those that appear when I type python-config --ldflags. I have also made sure that the Python I am using is definitely the Homebrew one by inserting export PATH="/usr/local/opt/python/libexec/bin:$PATH" into my .bash_profile as directed by Homebrew.
I am not sure whether this error is because of the Python update, the recent macOS Supplemental Update, or something else. Any idea what the problem could be?
Thanks
I had the same problem;
In python 2.7 the NumPy 1.8.0 was available,
Then I installed NumPy (again) using brew, and it wasn't available in my python (2.7) anymore. (Got the same error you got here)
So I did "brew unlink python && brew link python" to use python 3 (instead of 2) which NumPy 1.14 is available in it.
I guess the python 2.7 was not compatible with this recent version of NumPy.
I'm trying to import the skit-learn library but it´s generate this error:
Traceback (most recent call last):
File "<pyshell#13>", line 1, in <module>
import sklearn
File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\sklearn\__init__.py", line 134, in <module>
from .base import clone
File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\sklearn\base.py", line 12, in <module>
from .utils.fixes import signature
File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\sklearn\utils\__init__.py", line 11, in <module>
from .validation import (as_float_array,
File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\sklearn\utils\validation.py", line 18, in <module>
from ..utils.fixes import signature
File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\sklearn\utils\fixes.py", line 144, in <module>
from scipy.sparse.linalg import lsqr as sparse_lsqr # noqa
File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\scipy\sparse\linalg\__init__.py", line 114, in <module>
from .isolve import *
File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\scipy\sparse\linalg\isolve\__init__.py", line 6, in <module>
from .iterative import *
File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\scipy\sparse\linalg\isolve\iterative.py", line 7, in <module>
from . import _iterative
ImportError: DLL load failed: Não foi possível encontrar o módulo especificado.
Someone could say what's happening, I'm completely lost with this.
Thanks a lot
Sorry if this seems obvious but there's not a lot of information given here so i can't tell what you already tried or not.
This package isn't included in the standard library so you'd have to have downloaded/installed it before importing did you follow the instructions on the library's website? http://scikit-learn.org/stable/install.html
Edit: found a similar issue DLL Load Failed: The specified module could not be found [Python]
I was looking into this not too long ago, I think script on windows is a little tricky. SciPy has directions to an installer on their webpage https://www.scipy.org/install.html. If you've installed python specifically for this project I would go and get anaconda. You can uninstall the python you have or just tell anaconda to replace the path during installation.
Good luck!
Alright guys. I finally could solve the problem.
I don't know why, but I uninstall NumPy, SciPy and Scikit-Learn and install again using the binary files from here:
link
And it's work. All these libraries are working correctly.
Something was running wrong installing from pip.
Well, I think it's case closed. Thank you #Hopeful_O, #juanpa.arrivillaga, #abccd and #shadefc09 for the help.