I'm having an issue where my Cygwin Python installation does not recognize *.pyd files. It receives an ImportError: No module named 'understand' when attempting to import the *.pyd file. It is able to detect the file with os.path.exists().
I've experimented with other *.pyd files and have the same No module named XXX issue. I don't think it's a path issue as I tried putting .py files in the folder and was able to call them for other folders. What could I do to troubleshoot this issue?
(Mon Nov-11 4:42:49pm)-(CPU 27.4%:0:Net)-(ssia:/cygdrive/c/Program Files/SciTools/bin/pc-win64/python)-(11M:2)
python3
Python 3.4.5 (default, Oct 10 2016, 14:41:48)
[GCC 5.4.0] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
import understand
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'understand'
import os
os.path.exists("understand.pyd")
True
Hm, solved.... In some sense.
Cygwin's python does not allow the import of *.pyd files. I was forced to install a new version of python and use that instead.
Related
It seems like a very simple problem
we can see below that gnuradio.ctrlport can be imported
But gnuradio.ctrlport.GNURadioControlPortClient fails.
This would indicate that the GNURadioControlPortClient.py file is missing right?
bit#bit:~$ python3
Python 3.10.6 (main, Nov 2 2022, 18:53:38) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gnuradio
>>> import gnuradio.ctrlport
>>> import gnuradio.ctrlport.GNURadioControlPortClient
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'gnuradio.ctrlport.GNURadioControlPortClient'
Next we can see that the file with the same name does exist in the gnuradio/ctrlport directory! This doesn't make sense as I don't get how python cannot import a file that clearly is present.
bit#bit:/usr/local/lib/python3/dist-packages/gnuradio/ctrlport$ ls
GNURadio GNURadioControlPortClient.pyo GrDataPlotter.pyo __init__.pyc monitor.pyc RPCConnection.pyc RPCConnectionThrift.pyc
GNURadioControlPortClient.py GrDataPlotter.py icon.png __init__.pyo monitor.pyo RPCConnection.pyo RPCConnectionThrift.pyo
GNURadioControlPortClient.pyc GrDataPlotter.pyc __init__.py monitor.py RPCConnection.py RPCConnectionThrift.py
Sys.path returns the correct value.
>>> import sys
>>> print(sys.path)
['', '/usr/lib/python310.zip', '/usr/lib/python3.10', '/usr/lib/python3.10/lib-dynload', '/home/bit/.local/lib/python3.10/site-packages', '/usr/local/lib/python3.10/dist-packages', '/usr/lib/python3/dist-packages']
so I believe it is searching in the correct directory. But it can't find it.
For reference this error is for the gr-perf-monitorx tool for GNURADIO which is importing this file but failing.
EDIT: Added the local path to the code and it worked see the comment below
I've noticed that while I can point my environment variables to Anaconda's Python interpreter, I don't get a fully working Python environment when I execute python in the command prompt. Python will still launch, but many of its packages are "broken."
PROBLEM:
Anaconda's Python interpreter does launch when called from command prompt, but it isn't able to import some of its packages (numpy being one of them used in this example).
EXAMPLE(WINDOWS CMD):
> where python
C:\Anaconda3\python.exe
Great, python calls the right interpreter. Let's go in there and import numpy!
> python
Python 3.7.1 (default, Dec 10 2018, 22:54:23) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "C:\Anaconda3\lib\site-packages\numpy\core\__init__.py", line 16, in <module>
from . import multiarray
ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Anaconda3\lib\site-packages\numpy\__init__.py", line 142, in <module>
from . import add_newdocs
File "C:\Anaconda3\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\Anaconda3\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
from .type_check import *
File "C:\Anaconda3\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "C:\Anaconda3\lib\site-packages\numpy\core\__init__.py", line 26, in <module>
raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control). Otherwise reinstall numpy.
Original error was: DLL load failed: The specified module could not be found.
This is weird. Let's try launching "Anaconda Prompt", which appears to just be an activated Anaconda environment.
>python
Python 3.7.1 (default, Dec 10 2018, 22:54:23) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>>
Everything works fine this way.
SUMMARY:
I'm expecting Anaconda's Python interpreter to launch from the command prompt and behave just the way it would if launched from within the Anaconda Prompt (which appears to just be a command prompt with an activated Anaconda environment).
What can I do to be able to get a fully working Anaconda Python interpreter by just launching python from the Window's command prompt? Maybe what I'm really asking is, what do I need to change in my environment variables to ensure that the Anaconda environment is activated when I call on python from the command prompt?
Activating a conda environment can also change the PATH. I suggest you compare PATH before and after activating the environment.
I have installed python-2.7.5-5ubuntu3 and matplotlib-1.3.1-1ubuntu5 from the ubuntu 14.04 repository via apt-get. Trying to import the library in python 2.7 raises the following import error:
harold#ubuntu:~$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/share/pyshared/matplotlib/__init__.py", line 157, in <module>
from matplotlib.compat import subprocess
ImportError: No module named compat
>>>
I checked the directory /usr/share/pyshared/matplotlib and, indeed, cannot find any package called compat.
Any idea what is broken on my system?
Thanks!
I have found same problem on Ubuntu 16 & 14.
Possible source of the problem is damaged instance of matplotlib. Damaged instance overlaps working instance of matplotlib.
Please try to remove broken instance of matplotlib to solve the issue.
Firstly I have looked matplotlib instances:
find / |grep matplotlib | grep __init__\.py$ |more
Secondly I have deleted this folder:
find /usr/share/pyshared/matplotlib -delete
I'm seeing urlopen error when I try to do communication on HTTPS
<urlopen error unknown url type: https>
I searched for this error and found that this issue is related to ssl. I need to have _ssl.so file in my /usr/lib64/python2.7/lib-dynload/ folder. But the file is already present. I try to import ssl in python console and see the import error for ssl.
Here is the information of file
$ ll /usr/lib64/python2.7/lib-dynload/_ssl.so
-r-xr-xr-x. 1 root root 38544 Aug 9 2012 /usr/lib64/python2.7/lib-dynload/_ssl.so
And here is what I'm seeing on python console
Python 2.7.6 (default, Apr 14 2014, 02:00:55)
[GCC 4.7.2 20121109 (Red Hat 4.7.2-8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "ssl.py", line 60, in <module>
import _ssl # if we can't import it, let the error propagate
ImportError: No module named _ssl
Can anybody please help me figure out the issue?
I finally figure out the issue. There were 2 python installations. The installation i was checking for openssl lib, contained the file. But by default other installation of python was being used for running the programs. Once I switched to correct python installation, the error went away.
I am trying to create tempfile but my python versions do not allow me to proceed and give the following complaints.
Do I need to upgrade this version to use tempfile module.
Thanks
Python 2.4.3 (#1, Jan 9 2013, 06:47:03) [GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tempfile
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "tempfile.py", line 2, in ?
temp = tempfile.NamedTemporaryFile()
AttributeError: 'module' object has no attribute 'NamedTemporaryFile'
You are importing a local file. You have a file named tempfile.py in your local directory that masks the global module. import tempfile imports that file, not the standard library module.
Use print tempfile.__file__ to locate that file if you cannot find it. Rename that file to something else.
The Python 2.4 tempfile module supports NamedTemporaryFile without upgrading.