I presently have Python 2.7 installed, and have been attempting to get my pygeoprocessing module to work correctly (which appears to have been installed correctly). This is the version of Idle Python I am running:
"Python 2.7.10 (default, May 23 2015, 09:44:00) [MSC v.1500 64 bit (AMD64)] on win32"
When I type in "import pygeoprocessing" from the Idle command line, this is the error message . . .
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
import pygeoprocessing
File "C:\Python27\ArcGISx6410.4\lib\site-packages\pygeoprocessing\__init__.py", line 10, in <module>
from geoprocessing import *
File "C:\Python27\ArcGISx6410.4\lib\site-packages\pygeoprocessing\geoprocessing.py", line 25, in <module>
import scipy.interpolate
File "C:\Python27\ArcGISx6410.4\lib\site-packages\scipy\interpolate\__init__.py", line 160, in <module>
from .interpolate import *
File "C:\Python27\ArcGISx6410.4\lib\site-packages\scipy\interpolate\interpolate.py", line 15, in <module>
import scipy.linalg
File "C:\Python27\ArcGISx6410.4\lib\site-packages\scipy\linalg\__init__.py", line 161, in <module>
from .misc import *
File "C:\Python27\ArcGISx6410.4\lib\site-packages\scipy\linalg\misc.py", line 5, in <module>
from . import blas
***File "C:\Python27\ArcGISx6410.4\lib\site-packages\scipy\linalg\blas.py", line 155, in <module>
from scipy.linalg import _fblas
ImportError: DLL load failed: The specified module could not be found.
When I navigated to the folder mentioned ( . . . scipy\linalg\blas.py) I found that both blas.py and _fblas were present. Therefore I don't know why I got that last import error.
Is there something I can check?
Thanks!
Since you are on a windows box you may want to verify whether you have the 64-bit or the 32-bit version of python installed. That has caused problems for me in the past.
If the above listed methods do not work, try installing the module with pip.
And then try importing it.
C.f. How do I install pip on Windows?
Related
When using python through the commandline, I am able to import modules fine. However, when I build a python script in SublimeText3, some modules don't import. I generally receive the following error:
ImportError: DLL load failed: The specified module could not be found.
The problem looks to involve modules with dependencies on modules with a "_" prefix (_sqlite3, _ssl). For example:
File "C:\ProgramData\anaconda3\Lib\sqlite3\__init__.py", line 23, in <module>
from sqlite3.dbapi2 import *
File "C:\ProgramData\anaconda3\Lib\sqlite3\dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: DLL load failed: The specified module could not be found.
System:
Windows 10
SublimeText3 (freshly reinstalled during troubleshooting)
Python 3.7.3 [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
(freshly reinstalled during troubleshooting)
Both commandline and ST3 or pointing to same instance of Python.
This is the only python install on the machine.
Have used default Python build in ST3 and created a new build, both have same issue.
Results when using the commandline:
Python 3.7.3 (default, Mar 27 2019, 17:13:21) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import plotly
>>>
Results in ST3:
import plotly
Traceback (most recent call last):
File "C:\Users\usr\Desktop\scrap.py", line 1, in <module>
import plotly
File "C:\ProgramData\anaconda3\Lib\site-packages\plotly\__init__.py", line 32, in <module>
from plotly import (
File "C:\ProgramData\anaconda3\Lib\site-packages\plotly\graph_objs\__init__.py", line 3, in <module>
from plotly.basedatatypes import BaseLayoutType as _BaseLayoutType
File "C:\ProgramData\anaconda3\Lib\site-packages\plotly\basedatatypes.py", line 25, in <module>
from .callbacks import (Points, InputDeviceState)
File "C:\ProgramData\anaconda3\Lib\site-packages\plotly\callbacks.py", line 2, in <module>
from plotly.utils import _list_repr_elided
File "C:\ProgramData\anaconda3\Lib\site-packages\plotly\utils.py", line 262, in <module>
from chart_studio.utils import *
File "C:\ProgramData\anaconda3\Lib\site-packages\chart_studio\__init__.py", line 2, in <module>
from chart_studio import (plotly, dashboard_objs, grid_objs, session)
File "C:\ProgramData\anaconda3\Lib\site-packages\chart_studio\plotly\__init__.py", line 10, in <module>
from . plotly import (
File "C:\ProgramData\anaconda3\Lib\site-packages\chart_studio\plotly\plotly.py", line 38, in <module>
from chart_studio.plotly import chunked_requests
File "C:\ProgramData\anaconda3\Lib\site-packages\chart_studio\plotly\chunked_requests\__init__.py", line 1, in <module>
from . chunked_request import Stream
File "C:\ProgramData\anaconda3\Lib\site-packages\chart_studio\plotly\chunked_requests\chunked_request.py", line 4, in <module>
import ssl
File "C:\ProgramData\anaconda3\Lib\ssl.py", line 98, in <module>
import _ssl # if we can't import it, let the error propagate
ImportError: DLL load failed: The specified module could not be found.
[Finished in 2.9s]
Any help much appreciated, been stuck on this for days.
For those with a similar issue in the future, I've fixed this by uninstalling the Anaconda distribution of Python and replacing it with a base Python installation from Python.org, then installing packages using pip manually. While not the ideal solution, this has solved the issue so that when I build a Python script in ST3, all modules are imported fine.
I'm new to python, and I've been trying to find answers to this error but haven't found any that are helpful so far. I'm running Python 3.6.6 on x64 windows.
Python 3.6.6 (v3.6.6:4cf1f54eb7, Jun 27 2018, 03:37:03) [MSC v.1900 64 bit (AMD64)] on win32
I keep getting an ImportError whenever I try to run any scripts that use packages that call the ctypes module. The specific packages that it's happened with are scikit-learn and astropy. They both installed fine.
I downloaded dependency walker and tried to see if the packages were 32 instead of 64, but they are all 64, my python installation is 64, everything is 64! I literally don't know what the problem is. I'm not sure that ctypes is for sure the problem but I notice that every time I get this error the last thing before it says ImportError is always the line
from _ctypes import Union, Structure, Array
here is the full error message:
Traceback (most recent call last):
File "C:/Users/jdhaa/Documents/Coding/astro tutorial.py", line 1, in <module>
from astropy.utils.data import download_file
File "C:\Users\jdhaa\AppData\Local\Programs\Python\Python36\lib\site-packages\astropy\__init__.py", line 121, in <module>
_check_numpy()
File "C:\Users\jdhaa\AppData\Local\Programs\Python\Python36\lib\site-packages\astropy\__init__.py", line 109, in _check_numpy
from .utils import minversion
File "C:\Users\jdhaa\AppData\Local\Programs\Python\Python36\lib\site-packages\astropy\utils\__init__.py", line 16, in <module>
from .misc import *
File "C:\Users\jdhaa\AppData\Local\Programs\Python\Python36\lib\site-packages\astropy\utils\misc.py", line 293, in <module>
import ctypes
File "C:\Users\jdhaa\AppData\Local\Programs\Python\Python36\lib\ctypes\__init__.py", line 7, in <module>
from _ctypes import Union, Structure, Array
ImportError: DLL load failed: %1 is not a valid Win32 application.
Am i missing something? Any help would be appreciated.
By the way, I installed python x64 from the main python website, and all the packages were pip installed globally.
I usually work with python 2.7 but this time i have to test a script in python3.
It is already installed on my computer, however when i start "python3", then go "import numpy", it show me "cannot import name 'multiarray'.
I even installed anaconda3 to test, but nothing happens
myName:~/anaconda3/bin$ python3
Python 3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/numpy/__init__.py", line 180, in <module>
from . import add_newdocs
File "/usr/lib/python2.7/dist-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/usr/lib/python2.7/dist-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/usr/lib/python2.7/dist-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/usr/lib/python2.7/dist-packages/numpy/core/__init__.py", line 14, in <module>
from . import multiarray
ImportError: cannot import name 'multiarray'
I saw that it is looking in the lib/python2.7, but i cannot find what to do to get him search in the python3 library.
I already tried python -m pip install numpy, and tried to create a virtualenv in python3 but i still get the same error.
I cannot figure what to do. Can someone help me ?
I would like to add, i cannot start command with 'sudo' as i'm working on a client machine.
edit:
i tried #gehbiszumeis answer and got this:
myName:~ $ cd anaconda3/bin/
myName:~/anaconda3/bin $ source activate /home/myName/anaconda3
(base) myName:~/anaconda3/bin $ conda list numpy
# packages in environment at /home/myName/anaconda3:
#
# Name Version Build Channel
numpy 1.14.3 py36hcd700cb_1
numpy-base 1.14.3 py36h9be14a7_1
numpydoc 0.8.0 py36_0
(base) myName:~/anaconda3/bin $ python3
Python 3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/numpy/__init__.py", line 180, in <module>
from . import add_newdocs
File "/usr/lib/python2.7/dist-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/usr/lib/python2.7/dist-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/usr/lib/python2.7/dist-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/usr/lib/python2.7/dist-packages/numpy/core/__init__.py", line 14, in <module>
from . import multiarray
ImportError: cannot import name 'multiarray'
I see there is numpy 36 installed when i type conda list numpy, but it seems not to work.. Did i miss something ?
edit2:
After #Pal Szabo method, i tested command python3 -m pip install --upgrade pip and got this error :
(env) (base) myName:~/anaconda3/bin $ python3 -m pip install --upgrade pip
Traceback (most recent call last):
File "/home/myName/anaconda3/lib/python3.6/runpy.py", line 183, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/home/myName/anaconda3/lib/python3.6/runpy.py", line 142, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "/home/myName/anaconda3/lib/python3.6/runpy.py", line 109, in _get_module_details
__import__(pkg_name)
File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 4, in <module>
import locale
File "/home/myName/anaconda3/bin/env/lib/python3.6/locale.py", line 16, in <module>
import re
File "/home/myName/anaconda3/bin/env/lib/python3.6/re.py", line 142, in <module>
class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'`
It is a crazy mix between python3, python2.7 then again python3. I'm lost \o/
edit3:
I finally found my error.
It was a probleme with my PYTHONPATH, which was pointing somewhere where a .pth file was defined, with some hard link to python 2.7 libraries.
with a simple "unset PYTHONPATH" it works fine.
Thanks you all
I had the same problem, took me several hours to figure it out.
In my case, the PYTHONPATH was set to /usr/lib/python2.6/dist-packages/
changing it to /Users/xxx/miniconda3/lib/python3.7/site-packages/ resolved the issue.
Good luck.
Based what I can see from your code listing, it seems that the anaconda environment is not activated (this is usually indicated by the environments name in surrounding brackets () before the prompt). Because of that python3 tries to look for numpy and only finds the one you used for python 2.7 previously, which causes the error (see the python2.7 error messages)
Try
source activate <your-anaconda-environment>
Then your prompt should look like this
(<your-anaconda-environment>) myName:~/anaconda3/bin$
Numpy should be contained in the standard anaconda environment. Try then to check if numpy is installed within your environment with
conda list numpy
If there is no numpy listed, try to install it with pip as you wrote before.
If want to use python3, use pip3 instead of pip:
pip3 install numpy
You can try these too in terminal:
rm -Rf env
virtualenv -p python3 env
source env/bin/activate
python3 -m pip install --upgrade pip
pip3 install numpy
Also make sure that the first line of your script is
#!/usr/bin/python3
Don't write anything, even comments, before this.
I solved this problem changing the Python's version on VS Code. I was working with Python 3.7.4, now with the 3.7.8 one.
When I installed Numpy, it was stored in the folder of Python3.6. So I think that u could try to change the path or just change the Python's version
Loading rpy2 on a Jupyter Notebook or in the console brought me the following error :
Traceback (most recent call last):
File "/home/louis/anaconda3/lib/python3.5/runpy.py", line 184, in _run_module_as_main
"__main__", mod_spec)
File "/home/louis/anaconda3/lib/python3.5/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/louis/anaconda3/lib/python3.5/site-packages/rpy2/tests.py", line 23, in <module>
import rpy2.tests_rpy_classic
File "/home/louis/anaconda3/lib/python3.5/site- packages/rpy2/tests_rpy_classic.py", line 3, in <module>
import rpy2.rpy_classic as rpy
File "/home/louis/anaconda3/lib/python3.5/site-packages/rpy2/rpy_classic.py", line 5, in <module>
import rpy2.rinterface as ri
File "/home/louis/anaconda3/lib/python3.5/site-packages/rpy2/rinterface/__init__.py", line 92, in <module>
from rpy2.rinterface._rinterface import (baseenv,
ImportError: /home/louis/anaconda3/lib/libgomp.so.1: version `GOMP_4.0' not found (required by /usr/lib/R/lib/libR.so)
R version : 3.2.3
Python version : 3.5.2 :: Anaconda custom (64-bit)
OS : ubuntu 16.04 LTS 64 bit
rpy2 version : 2.8.5
I don't know how relevant it may be, but I have gcc installed, and I can import rpy2 in python.
Any help or hint would be greatly appreciated.
Following omri_saadon's comment, I set LD_LIBRARY_PATH to all paths that led to a libgomp directory, which are :
$HOME/anaconda3/pkgs/gcc-4.8.5-7/lib
$HOME/anaconda3/pkgs/libgcc-4.8.5-2/lib
$HOME/anaconda3/pkgs/lib
but each time got the same error :
ImportError: path_to_libgomp/libgomp.so.1: version `GOMP_4.0' not found (required by /usr/lib/R/lib/libR.so)
So my quest goes on ^^ (I must admit I don't really know the ins and outs of what I am doing).
When I succeed in setting export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu (found in root mode) I have another kind of error :
import rpy2.rinterface as ri
File "/home/louis/anaconda3/lib/python3.5/site- packages/rpy2/rinterface/__init__.py", line 92, in <module>
from rpy2.rinterface._rinterface import (baseenv,
ImportError: /home/louis/anaconda3/bin/../lib/libreadline.so.6: undefined symbol: PC
and when I then try to import first the readline package (as it seems to have worked with some) I get :
import rpy2.rinterface as rinterface
File "/home/louis/anaconda3/lib/python3.5/site-packages/rpy2/rinterface/__init__.py", line 92, in <module>
from rpy2.rinterface._rinterface import (baseenv,
ImportError: /usr/lib/libblas.so.3: undefined symbol: gotoblas
It appears I finally succeeded in installing and using rpy2.
What I did ?
I installed it with the conda package manager, and not pip. With just conda install rpy2, I was done.
Have you tried
RUN conda install -y gcc
That seems to work for people with similar issues -- Missing GOMP_parallel or GOMP_4.0 in (Docker) jupyter/all-spark-notebook: both R and Python
I have a C++ program, which has an embedded python 3.4.3+. I am attempting to run a script which uses a module named requests, this module depends on socket, but the embedded interpreter in unable to import _socket
Python Version and Callstack
3.4.3+ (3.4:f4cd9ac378d7+, Feb 16 2016, 21:24:03) [MSC v.1800 32 bit (Intel)]
Traceback (most recent call last):
File "<project path>\client_example.py", line 30, in <module>
import requests
File "F:\Python 3.4.3\lib\site-packages\requests\__init__.py", line 58, in <module>
from . import utils
File "F:\Python 3.4.3\lib\site-packages\requests\utils.py", line 12, in <module>
import cgi
File "F:\Python 3.4.3\Lib\cgi.py", line 39, in <module>
from email.parser import FeedParser
File "F:\Python 3.4.3\Lib\email\parser.py", line 12, in <module>
from email.feedparser import FeedParser, BytesFeedParser
File "F:\Python 3.4.3\Lib\email\feedparser.py", line 27, in <module>
from email import message
File "F:\Python 3.4.3\Lib\email\message.py", line 16, in <module>
from email import utils
File "F:\Python 3.4.3\Lib\email\utils.py", line 29, in <module>
import socket
File "F:\Python 3.4.3\Lib\socket.py", line 49, in <module>
import _socket
ImportError: No module named '_socket'
I also know that _socket.pyd is located in DLLs in the python install location, however I don't know if it should also be in another location.
How can I make my program's embedded interpreter find the _socket module?
Have you tried opening the python terminal and load the socket library? (i.e. "import socket")
I see you are using MSVC, meaning you are using windows. To open the python terminal open a command prompt and just type python and press enter. You are now in the python terminal.
If that does not work, then there is a problem with the python installation.
Another thing, if you installed python using a proper python installer well the problem will most probably not be due to a bad install.
Best regards.
try adding the path to the module to python:
sys.path.append(path/to/module)
this should allow you to import the module.
This happened to me while debugging my c++ application in VS 2019.
Because Python is missing the debug compiled files: _d.dll _d.pyd *d_.lib
Solution:
download the source code and build your debug version
Debug Version Build
copy from .\PCbuild\amd64 to your python directory
*._d.dll ==> .\%PYTHONHOME%\
*._d.pyd ==> .\%PYTHONHOME%\DLLs
*._d.pdb ==> .\%PYTHONHOME%\DLLs
*._d.lib ==> .\%PYTHONHOME%\libs
Set environment variables %PYTHONHOME% and %PYTHONPATH%
Add the path to sys.path
PyObject* sys_path = PySys_GetObject("path");
retVal = PyList_Append(sys_path, PyUnicode_FromString("C:\\Python38_64\\DLLs"));
try debugging again ;-)