Enthought Canopy - "IOError: [Errno 10038]" when install or update packages in Package Manager - enthought

I have installed Canopy 1.7.4.3348 (64 bit). My OS is Windows 10 (64 bit). I have the most updated Canopy and Windows 10.
When I tried to update and install any packages in Package Manager, the "Status" would turn out to be "Error", and I got the message:
IOError: [Errno 10038] An operation was attempted on something that is not a socket.
I looked up the Error code on microsoft.com (https://msdn.microsoft.com/en-us/library/windows/desktop/ms740668(v=vs.85).aspx) and found Microsoft's definition of socket error 10038:
WSAENOTSOCK 10038
Socket operation on nonsocket.
An operation was attempted on something that is not a socket.
Either the socket handle parameter did not reference a valid socket,
or for select, a member of an fd_set was not valid.
I think this error from Canopy may only exist in Windows but not in other OS like Linux. Could anyone please kindly help with this issue? Really appreciate it!!
The detailed messages are as below:
Warming up...
Traceback (most recent call last):
File "build\bdist.win-amd64\egg\canopy_dashboard\packman\package_action_worker.py", line 54, in run
File "build\bdist.win-amd64\egg\canopy_dashboard\packman\package_action.py", line 193, in execute
File "build\bdist.win-amd64\egg\canopy_dashboard\packman\packman.py", line 346, in <lambda>
File "build\bdist.win-amd64\egg\canopy_dashboard\packman\packman.py", line 893, in _install
File "build\bdist.win-amd64\egg\canopy_platform\cpython_packages_manager.py", line 98, in install_package
File "build\bdist.win-amd64\egg\canopy_platform\enpkg_api.py", line 102, in install_package
File "build\bdist.win-amd64\egg\canopy_platform\enpkg_api.py", line 177, in _execute_in_subprocess
File "build\bdist.win-amd64\egg\canopy_platform\enpkg_api.py", line 212, in _propagate_progress_events
IOError: [Errno 10038] An operation was attempted on something that is not a socket

Please file a bug report from the Canopy help menu for Enthought tech support records (and please refer to this SO question in your report).
I don't know what causes this rare error, but it should disappear in Canopy 2.0, which uses a different package manager backend, based on the Enthought Deployment Manager (EDM).
Meanwhile, you can avoid the error by using the command-line package installer, enpkg, from a Canopy Command Prompt. Please see this Knowledge Base article for details: https://support.enthought.com/entries/22415022-Using-enpkg-to-update-Canopy-EPD-packages.

Related

Eclipse / PyDev Stop button not working with OSError: [WinError 6] The handle is invalid error

I have the following Eclipse version on Windows 10:
Version: 2020-09 (4.17.0)
Build id: 20200910-1200
I am using PyDev along with it.
In my code I am using selenium to make a number of url calls (web scraping). When it happens that a particular url is not present or at least not present in the way most of the urls I am reading are, I get the following error:
Traceback (most recent call last):
File "C:\Users\foobar\eclipse-workspace\WeatherUndergroundUnderground\historical\BWI_Fetch.py", line 44, in <module>
main(city, month_date, start_year, end_year)
File "C:\Users\foobar\eclipse-workspace\WeatherUndergroundUnderground\historical\BWI_Fetch.py", line 22, in main
driver.get(city_url);
File "C:\Users\foobar\AppData\Local\Programs\Python\Python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 333, in get
self.execute(Command.GET, {'url': url})
File "C:\Users\foobar\AppData\Local\Programs\Python\Python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Users\foobar\AppData\Local\Programs\Python\Python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Reached error page: about:neterror
Exception ignored in: <function Popen.__del__ at 0x0000019267429F70>
Traceback (most recent call last):
File "C:\Users\foobar\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 945, in __del__
self._internal_poll(_deadstate=_maxsize)
File "C:\Users\foobar\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 1344, in _internal_poll
if _WaitForSingleObject(self._handle, 0) == _WAIT_OBJECT_0:
OSError: [WinError 6] The handle is invalid
When I get this particular error, eclipse is still running and pushing the red stop button does not work to end the program. I can usually use the red stop button for just about any other python program I have written, but this code/error seems to hang things. How can I end the process from within the Eclipse application?
The error in the stack trace is not really related to PyDev, so, the stack trace error is only really fixable in Selenium/Python (the error says that it's trying to access a process which is already dead on the __del__).
Now, related to the reason why PyDev wasn't able to kill it, I think that you probably have some process which spawned a subprocess and is not reachable anymore because the parent process died and thus it's not possible to create a tree to kill that process from the initial process launched in PyDev.
The actual code which does this in PyDev is: https://github.com/fabioz/winp/blob/master/native/winp.cpp#L208
I think that it should be possible to use the windows api to create a JobObject and then AssignProcessToJobObject and on kill also kill the JobObject so that it kills all associated processes so that things are setup in a way that that this doesn't happen, but this isn't currently done.
As a note, usually I have an alias for: taskkill /im python.exe /f (which will kill all the python.exe processes running in the machine) and it's what I usually use in such cases, so, if something like that happens I just kill all the python.exe processes in the machine.
Although note that if you spawned some other process... say, chrome.exe -- in that process tree, that process must also be killed for the initial shell that launched python to be really disposed.
This error message...
Exception ignored in: <function Popen.__del__ at 0x0000019267429F70>
...implies that the builtins module was destroyed before running __del__ in process of garbage collecting.
Hence PyDev is no more able to communicate with the relevant python modules. As a result Stop button isn't functioning and raises the error:
OSError: [WinError 6] The handle is invalid

Issue with whois and subprocess (Python 3.4; 64-bit Windows)

So I'm just trying to get the suggested query (domain = whois.query("google.com")) working. But whenever I run it, I get the following traceback:
File "file.py", line x, in weight_sources
domain = whois.query("google.com")
File "C:\Users\User Name\Anaconda3\lib\site-packages\whois\__init__.py", line 50, in query
pd = do_parse(do_query(d, force, cache_file, slow_down, ignore_returncode), tld)
File "C:\Users\User Name\Anaconda3\lib\site-packages\whois\_1_query.py", line 44, in do_query
_do_whois_query(dl, ignore_returncode),
File "C:\Users\User Name\Anaconda3\lib\site-packages\whois\_1_query.py", line 58, in _do_whois_query
p = subprocess.Popen(['whois', '.'.join(dl)], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
File "C:\Users\User Name\Anaconda3\lib\subprocess.py", line 856, in __init__
restore_signals, start_new_session)
File "C:\Users\User Name\Anaconda3\lib\subprocess.py", line 1111, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
I've seen some other questions/answers point to line 1111 in subprocess, but I think the issue might be in whois as I have used subprocess extensively without error on my device. Since the non-existent file seems to be related to the whois package, I don't think this question is related to this one, although the two could be related?
Essentially, is there any work around for this error or if I need to edit the whois package code, how would I go about that? I'm not exactly sure I even fully understand what "file" is missing...
The missing file is the whois executable, which is opened here:
subprocess.Popen(['whois', '.'.join(dl)]
The package description says whois is a wrapper for the Linux whois command. That means you must be running on Linux and have whois installed, but you are running Windows.
So I think you're out of luck with this package, maybe another one (such as python-whois) supports Windows.

Spyder/Pythonxy crashes

Upon installing python xy 2.7.5 on my laptop, I tried to launch the Spyder IDE. This yielded the following error:
C:\Python27\Scripts>spyder.exe
Traceback (most recent call last):
File "C:\Python27\Scripts\spyder-script.py", line 9, in
load_entry_point('spyder==2.2.0', 'console_scripts', 'spyder')()
File "C:\Python27\lib\site-packages\spyderlib\start_app.py", line 72, in main
from spyderlib import spyder
File "C:\Python27\lib\site-packages\spyderlib\spyder.py", line 112, in
from spyderlib.plugins.ipythonconsole import IPythonConsole
File "C:\Python27\lib\site-packages\spyderlib\plugins\ipythonconsole.py", line 31, in
from IPython.frontend.qt.kernelmanager import QtKernelManager
File "C:\Python27\lib\site-packages\IPython\frontend\qt\kernelmanager.py", line 9, in
from IPython.zmq.kernelmanager import KernelManager, SubSocketChannel, \
File "C:\Python27\lib\site-packages\IPython\zmq\__init__.py", line 67, in
check_for_zmq('2.1.4')
File "C:\Python27\lib\site-packages\IPython\zmq\__init__.py", line 51, in check_for_zmq
import zmq
File "C:\Python27\lib\site-packages\zmq\__init__.py", line 35, in
_libzmq = ctypes.CDLL(bundled[0], mode=ctypes.RTLD_GLOBAL)
File "C:\Python27\lib\ctypes\__init__.py", line 365, in __init__
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 127] Die angegebene Prozedur wurde nicht gefunden
Using a python console, I was able to run python code as well as matplotlib and numpy code. Ipython works, however Ipython (Qt) does not work. what could be the reason for this?
The host OS is Windows XP.
This is actually a problem with the most recent builds of zeromq, which are messaging libraries that are required for IPython, and not with Spyder itself. The latest zeromq builds are not compatible with Win XP. This is a know issue with recent versions of Python(x,y) on Win XP which can be solved by following the guidance in this bug report.
It works by installing
https://pythonxy.googlecode.com/files/pyzmq-13.0.2-4_py27.exe
and
http://h5py.googlecode.com/files/h5py-2.1.3.win32-py2.7.msi
,
As it is posted in http://code.google.com/p/pythonxy/issues/detail?id=670

Using Gurobi solver in the Enthought Canopy Editor on Linux

I am currently working with Gurobi solver using python. Previously, I have just been using a mix of a text editor and the terminal to write and run my models but I am currently experimenting with using Enthought Canopy Editor. I have a model that is works when I run in in the terminal using python model.py but when I try doing%run model.py in Canopy's iPython shell I get:
%run /home/cdhagmann/Copy/Code_Env/Farmer/model.py
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
/home/cdhagmann/Canopy/appdata/canopy-1.0.1.1189.rh5-x86_64/lib/python2.7/site-packages/IPython/utils/py3compat.pyc in execfile(fname, *where)
181 else:
182 filename = fname
--> 183 __builtin__.execfile(filename, *where)
/home/cdhagmann/Copy/Code_Env/Farmer/model.py in <module>()
----> 1 from gurobipy import *
2 from data_IO import read_data,currency
3 import time
4
5 # Import model data
ImportError: No module named gurobipy
My guess is that the terminal and Canopy look for modules in different places but I don't know how to rectify it. I found this reference on the Gurobi group site about Enthought Canopy and Gurobi on OS X 10.8 but didn't know how much those instruction would differ from doing it on Linux and even what he meant about installing Gurobi in Canopy's site-packages.
UPDATE: Based on information found the first link I clicked on, I did in fact leave the boxed clicked making Canopy my default directory. You have to manually prepend the PATH variable, which I missed them saying that I had to do. So I did that. I now have Canopy's version of iPython running in my terminal (check by using sys.path); however, I get a huge list of errors when I try run python.
cdhagmann#Crispin ~ $ python
Traceback (most recent call last):
File "/usr/lib/python2.7/site.py", line 563, in <module>
main()
File "/usr/lib/python2.7/site.py", line 545, in main
known_paths = addusersitepackages(known_paths)
File "/usr/lib/python2.7/site.py", line 272, in addusersitepackages
user_site = getusersitepackages()
File "/usr/lib/python2.7/site.py", line 247, in getusersitepackages
user_base = getuserbase() # this will also set USER_BASE
File "/usr/lib/python2.7/site.py", line 237, in getuserbase
USER_BASE = get_config_var('userbase')
File "/usr/lib/python2.7/sysconfig.py", line 578, in get_config_var
return get_config_vars().get(name)
File "/usr/lib/python2.7/sysconfig.py", line 505, in get_config_vars
import re
File "/usr/lib/python2.7/re.py", line 105, in <module>
import sre_compile
File "/usr/lib/python2.7/sre_compile.py", line 14, in <module>
import sre_parse
File "/usr/lib/python2.7/sre_parse.py", line 17, in <module>
from sre_constants import *
File "/usr/lib/python2.7/sre_constants.py", line 18, in <module>
from _sre import MAXREPEAT
ImportError: cannot import name MAXREPEAT
Suggestions?
And to answer #Jonathan questions:
sys.prefix = '/usr'
sys.path:
/usr/lib/python2.7
/usr/lib/python2.7/plat-x86_64-linux-gnu
/usr/lib/python2.7/lib-tk
/usr/lib/python2.7/lib-old
/usr/lib/python2.7/lib-dynload
/usr/local/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages/PILcompat
/usr/lib/python2.7/dist-packages/gtk-2.0
/usr/lib/pymodules/python2.7
/usr/lib/python2.7/dist-packages/ubuntu-sso-client
gurobipy.__file__ = '/usr/local/lib/python2.7/dist-packages/gurobipy/gurobipy.so'
If the terminal is correctly configured for Canopy Python, then python in terminal and Canopy Python should be looking for modules in the same places. If during installation, you disabled "make Canopy be default Python", or if you have not restarted terminal since installation, then it won't automatically be configured correctly.
These articles should help you understand and configure:
http://docs.enthought.com/canopy/configure/faq.html#where-are-all-of-the-python-packages-in-my-user-python-environment
https://support.enthought.com/entries/23646538-Make-Canopy-s-Python-be-your-default-Python-i-e-on-the-PATH-
https://support.enthought.com/entries/23389761-Installing-packages-into-Canopy-Python-from-the-command-line
If these articles do not suffice for you to solve this, then please report -- when you run python from terminal, what are these?
sys.prefix
sys.path
gurobipy.__file__

iptest3 with IPython

I'm brand new to Python programming and trying to get myself a functional base from which I can run things like the IPython Notebook which looks pretty exciting.
Thus far I have both Python 2.7 and 3.3 from python.org installed in OS X 10.6 (Snow Leopard) as well as ActiveTcl 8.5.13. Almost everything that I've tried thus far works as expected. I'm focused on learning 3.3, but want to have the option of using 2.7 too. I read up in several documents that I need to start gaining access to PyPI packages using a Python package manager and that distribute is the one I should use for 3k. So I installed that according to the documentation I found and it seemed to work fine.
I also installed pip as directed, and a number of others.
At this point, I have:
$ pip freeze
distribute==0.6.34
ipython==0.13.1
nose==1.2.1 (installed after IPython)
pexpect==2.4 (installed after IPython)
pyflakes3k==0.4.3
readline==6.2.4.1 (installed after IPython)
At this point, I'm doing this from ipython.org guidance
And when I did $ easy_install pexpect, I got a bunch of errors:
$ easy_install pexpect
Searching for pexpect
Reading http://pypi.python.org/simple/pexpect/
Reading http://pexpect.sourceforge.net/
Reading http://sourceforge.net/project/showfiles.php?group_id=59762
Best match: pexpect 2.4
Downloading http://pypi.python.org/packages/source/p/pexpect/pexpect-2.4.tar.gz#md5=fe82d69be19ec96d3a6650af947d5665
Processing pexpect-2.4.tar.gz
Writing /var/folders/td/td0Sh8EfGFuMCnKex1v+q++++TI/-Tmp-/easy_install-s4dtyy/pexpect-2.4/setup.cfg
Running pexpect-2.4/setup.py -q bdist_egg --dist-dir /var/folders/td/td0Sh8EfGFuMCnKex1v+q++++TI/-Tmp-/easy_install-s4dtyy/pexpect-2.4/egg-dist-tmp-5h5cg4
File "build/bdist.macosx-10.6-intel/egg/fdpexpect.py", line 36
raise ExceptionPexpect, 'The fd argument is not a valid file descriptor.'
^
SyntaxError: invalid syntax
File "build/bdist.macosx-10.6-intel/egg/FSM.py", line 77
return `self.value`
^
SyntaxError: invalid syntax
File "build/bdist.macosx-10.6-intel/egg/pexpect.py", line 82
except ImportError, e:
^
SyntaxError: invalid syntax
zip_safe flag not set; analyzing archive contents...
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pexpect-2.4-py3.3.egg/fdpexpect.py", line 36
raise ExceptionPexpect, 'The fd argument is not a valid file descriptor.'
^
SyntaxError: invalid syntax
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pexpect-2.4-py3.3.egg/FSM.py", line 77
return `self.value`
^
SyntaxError: invalid syntax
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pexpect-2.4-py3.3.egg/pexpect.py", line 82
except ImportError, e:
^
SyntaxError: invalid syntax
Adding pexpect 2.4 to easy-install.pth file
Installed /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pexpect-2.4-py3.3.egg
Processing dependencies for pexpect
Finished processing dependencies for pexpect
That looks bad to me (although I don't yet have the expertise to really interpret it), and so I'm not sure if I have a complete install of pexpect.
After installing nose (before pexpect as per URL above), I tried running iptest and iptest3 from the command line, and both failed to find the command, but after I did easy_install ipython again (after nose), I noticed that this install added iptest3 (as well as ipcluster3 and a few other scripts) to my path, and now my bash shell can find iptest3, but when I run it, I get some more bad-looking output:
$ iptest3
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.3/bin/iptest3", line 9, in <module>
load_entry_point('ipython==0.13.1', 'console_scripts', 'iptest3')()
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/distribute-0.6.34-py3.3.egg/pkg_resources.py", line 343, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/distribute-0.6.34-py3.3.egg/pkg_resources.py", line 2308, in load_entry_point
return ep.load()
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/distribute-0.6.34-py3.3.egg/pkg_resources.py", line 2014, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/IPython/__init__.py", line 43, in <module>
from .config.loader import Config
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/IPython/config/__init__.py", line 16, in <module>
from .application import *
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/IPython/config/application.py", line 31, in <module>
from IPython.config.configurable import SingletonConfigurable
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/IPython/config/configurable.py", line 26, in <module>
from .loader import Config
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/IPython/config/loader.py", line 27, in <module>
from IPython.utils.path import filefind, get_ipython_dir
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/IPython/utils/path.py", line 25, in <module>
from IPython.utils.process import system
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/IPython/utils/process.py", line 27, in <module>
from ._process_posix import _find_cmd, system, getoutput, arg_split
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/IPython/utils/_process_posix.py", line 22, in <module>
from IPython.external import pexpect
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/IPython/external/pexpect/__init__.py", line 2, in <module>
import pexpect
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pexpect-2.4-py3.3.egg/pexpect.py", line 82
except ImportError, e:
^
SyntaxError: invalid syntax
After doing all that, I noted that my /Library/Frameworks/Python.framework/Versions/Current had been pointing to 2.7, and I guessed that that might be related to my problems and changed the symbolic link to point to 3.3, but iptest3 still fails with the error above.
Any other thoughts on what to do to fix this? It's clear that iptest is pretty important to doing anything else (like IPython Notebook) I want to do.
There is a py3-compatible fork of pexpect called pexpect-u (the u is for unicode, the main difference between the two). You need this to run the pexpect-based parts of IPython on Python 3.
Should be a simple
pip install pexpect-u
side note: pexpect-u is by IPython developer Thomas Kluyver, who did most of the heavy lifting bringing py3 compatibility to IPython.