I am trying to install python. Or actually, have installed and deinstalled it a few times now. I am using pythonxy with the spyder IDE (i am used to matlab is why i want to use spyder). The 3.3.2 python would not even start with spyder on my win8 machine, so now I have the 2.7 version installed.
Spyder starts up now, but upon startup I get `'import sitecustomize' failed? in my console and python wont execute any commands I enter. After the error the startupscript keeps on going forever without doing anything and I cant do anything either anymore. The error tells me to start python with -v appendix, output below.
I have googled this error which gave me two possible solutions:
i should edit python.rb
https://github.com/mxcl/homebrew/commit/10ba101c323f98118b427f291e15abc5b3732991
or i should apply this (attachment in last post there) to sitecustomize
https://code.google.com/p/spyderlib/issues/detail?id=771
Applying the diff file did not help and as mata explains below the .rb file is used during install, so not applicable to my problem.
So my question: Does anybody know how to fix this bug from experience?
The error:
'import sitecustomize' failed; use -v for traceback
Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
The traceback:
C:\Python27\lib\site-packages\spyderlib\pil_patch.pyc matches C:\Python27\lib\site-packages\spyderlib\pil_patch.py
import spyderlib.pil_patch # precompiled from C:\Python27\lib\site-packages\spyderlib\pil_patch.pyc
Traceback (most recent call last):
File "C:\Python27\lib\site.py", line 498, in execsitecustomize
import sitecustomize
File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 174, in <module>
os.environ["SPYDER_AR_STATE"].lower() == "true")
File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\monitor.py", line 146, in __init__
self.n_request.connect( (host, notification_port) )
File "C:\Python27\lib\socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 10061] No connection could be made because the target machine actively refused it
Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
(Spyder dev here) I'm almost sure your problem is because of a firewall issue. It seems your firewall is too strict and it's blocking all attempts to try to open a port for our purposes.
To avoid blocking the full application while evaluating stuff, we run our python interpreter on a different process than the one Spyder runs on. We communicate with that process using a simple sockets protocol, which opens a new port on your machine and sends data back and forth between the console and Spyder through that port.
That's also the reason why you are not seeing the error on a regular python interpreter: because it doesn't need to open a port to run.
Following Carlos Cordoba's answer, I did the following (using Ubuntu 15.10):
1-) Disabled the firewall
sudo ufw disable
2-) Reset spyder and applied default settings:
spyder --reset
spyder --default
3-) Ran Spyder again
spyder
4-) Enabled the firewall
sudo ufw enable
And it is working normally now.
After fumbling with the firewall settings, I couldn't find any that would make spyder work.
Some runs would work, others would not, with the exact same configuration.
I'd rule out the firewall for now.
I noticed that the port that sitecustomize attempts to connect to is not listening.
Setting SPYDER_DEBUG=True before launching spyder gives more details:
Traceback (most recent call last):
File "P:\Python33\lib\threading.py", line 637, in _bootstrap_inner
self.run()
File "P:\Python33\lib\site-packages\spyderlib\widgets\externalshell\introspection.py", line 64, in run
sock.bind( ("127.0.0.1", self.port) )
OSError: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions`
I did a dirty hack by replacing the line:
sock.bind( ("127.0.0.1", self.port) )
by the following:
for loopCount in range(10, -1, -1):
try:
sock.bind( ("127.0.0.1", self.port) )
break
except OSError:
if DEBUG:
logging.debug('Notification server: Bind on port %d failed...' % (self.port))
if not loopCount:
raise
import time
time.sleep(1)
It seems to work, but this may be more luck than anything else...
Versions:
Spyder 2.3.0dev1
python 3.3.2 (64 bit)
I had this same problem. worked on it for months...
the spyder from from the EPEL library for Redhat 7 (Scientific Linux).
Finally figured out I needed a extra package that was not set as a requirement. python-matplotlib
After adding that python package all my problems went away!
Arrrggghhhhh.......!!!!!
Related
I'm running Python 3.5.6 on a distribution where TLS versions below 1.2 have been compiled out of OpenSSL by passing these options to ./configure: no-ssl no-tls1 no-tls1_1 no-ssl3-method no-tls1-method no-tls1_1-method. The OpenSSL version is 1.1.1d. Python 3 is built from source at distro build time and linked against the version of OpenSSL included in the distro.
Everything builds successfully, but when I try to import the ssl library in Python, I get the following error:
$ python3
Python 3.5.6 (default, Mar 23 2020, 05:11:33)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.5/ssl.py", line 99, in <module>
import _ssl # if we can't import it, let the error propagate
ImportError: /usr/lib/python3.5/lib-dynload/_ssl.cpython-35m-aarch64-linux-gnu.so: undefined symbol: TLSv1_method
I don't understand why this error occurs at runtime. The only reference I can find in the Python 3.5.6 code to TLSv1_method is line 3088 of _ssl.c:
ctx = SSL_CTX_new(TLSv1_method());
Using no-tls1-method does compile out the implementation of TLSv1_method, and that line in the Python code is not guarded by any #ifdef. But I'd expect that to cause a failure at link time for the _ssl.cpython-35m-aarch64-linux-gnu.so module, not at runtime when Python tries to import the module. What's going on here, and is there a way to fix it without patching Python? I cannot upgrade the version of OpenSSL or Python in use.
It seems that my confusion resulted from misunderstanding how _ssl.cpython-35m-aarch64-linux-gnu.so links to OpenSSL. I assumed that it was statically linked, but it's actually dynamically linked to libssl.so. This is why the error occurs at runtime when the shared object is loaded.
It seems, then, that the only way to fix this without updating Python is to patch the call to TLSv1_method to use the generic TLS_method instead. I'll leave this question open for a few days though in case anyone has a better suggestion.
Edit: I filed a Python bug for this issue. It should be fixed in a future release.
I successfully compiled net-snmp-5.7.3 on Ubuntu. :D This is the specific version of Ubuntu:
Linux loserBox 3.13.0-32-generic #57-Ubuntu SMP Tue Jul 15 03:51:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
I seemed to have successfully installed the Python bindings for net-snmp too. This is included with the net-nsmp download as a different folder titled 'Python' with the setup.py file in it. However when running the command python setup.py test I noticed some problems. I thought this may be nothing to worry about so I went ahead and executed python setup.py install I was not sure what the instructions meant in the README file that say, "python setup.py test (requires a locally running agent w/ config provided)". So, this is why I installed it with the failed test or something. Anyways, I am not sure if this is a problem or not.
After successfully installing the python bindings for net-snmp I switched directories back to my Desktop and opened up an interactive python shell. From here I imported the netsnmp module and received the below error. It almost looks like there is a spelling error in the variable netsnmp_memdup that is throwing the error in the Traceback. This looks like a problem with the C code and not 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 netsnmp
/usr/lib/python2.7/dist-packages/pkg_resources.py:1031: UserWarning:
/home/loser_user/.python-eggs is writable by group/others and vulnerable to attack
when used with get_resource_filename. Consider a more secure location
(set with .set_extraction_path or the PYTHON_EGG_CACHE environment variable).
warnings.warn(msg, UserWarning)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.linux-x86_64/egg/netsnmp/__init__.py", line 1, in <module>
File "build/bdist.linux-x86_64/egg/netsnmp/client.py", line 1, in <module>
File "build/bdist.linux-x86_64/egg/netsnmp/client_intf.py", line 7, in <module>
File "build/bdist.linux-x86_64/egg/netsnmp/client_intf.py", line 6, in __bootstrap__
ImportError: /home/loser_user/.python-eggs/netsnmp_python-1.0a1-py2.7-linux-x86_64.egg-
tmp/netsnmp/client_intf.so: undefined symbol: netsnmp_memdup
Does anyone know how to fix this problem? I looked on the mailing list page on sourceforge for this project and searched the supoort archives but did not find anything.
Thanks for listening to a crazy man's Python problems.
Happy Holidays,
user_loser
Alrgihty, thanks to my good friend Naveen, we have traced this down to an actual bug in the Python Net-SNMP bindings in the 5.7.3.
There are two ways around this:
Use the Python bindings in Net-SNMP 5.7.2
See this commit on our fork of the Net-SNMP Python library (only started yesterday so bear with us): https://github.com/fgimian/easysnmp/commit/fa86af977b563f65e7d70243752d48b94a8d5686 and replicate this in your download of Net-SNMP.
I am trying to resolve some dependencies for the MYSQL connector for Python on Angstrom.
From the command line I get the following error:
Python 2.6.6 (r266:84292, Feb 25 2011, 16:50:01)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import io
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named io
I thought that IO was a base-level module. It appears to be up-to-date:
# opkg install python-core
Package python-core (2.6.6-ml12.2.6) installed in root is up to date.
Shouldn't IO be available by default, and what can I do to resolve this issue?
Thanks to Padraic Cunningham who lead me on the path to a solution.
I found that several files, including io.py were missing from the install. Building the Angstrom for the Beagleboard (XM) image from the Angstrom website did not include these files (or subsequent modifications I made deleted them?). I rebuilt Python, keeping the identical version, from the Python source.
I had to then rebuild the MySQL connector (from MySql/Oracle). (All my other modules including OpenCV continued to work without issue)
This worked and I am now able to query the database.
One additional note. Once all the dependencies were resolved, I still could not connect to the database. The problem was that the MySQL connector was assuming a TCP/IP connection rather than file based socket. So I had to add the following to the connection string:
unix_socket="/tmp/mysql.sock"
Such that the full connection string looked like this:
cnx = mysql.connector.connect(user='username', password='password', host='localhost', database='dbname', raise_on_warnings=True, unix_socket="/tmp/mysql.sock")
Im working on a little project that running rabbitmq with python, I need a way to access the management api and pull stats, jobs, etc. I have tried using pyRabbit, but doen't appear to be working unsure why, hoping better programmers might know? Below I was just following the basic tutorial and readme to perform the very basic task. My server is up, I'm able to connect outside of python and pyrabbit fine. I have installed off the dependencies with no luck, at least I think. Also open to other suggestions for just getting queue size, queues, active clients etc outside of pyRabbit.
'Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\user>python
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
import nose
import httplib2
import mock
from pyrabbit.api import Client
import pyrabbit
cl = Client('my.ip.com:15672', 'guest', 'guest')
cl.is_alive()
No JSON object could be decoded - (Not found.) ()
Traceback (most recent call last):
File "", line 1, in
File "C:\Python27\lib\site-packages\pyrabbit\api.py", line 48, in wrapper if self.has_admin_rights:
File "C:\Python27\lib\site-packages\pyrabbit\api.py", line 175, in has_admin_right whoami = self.get_whoami()
File "C:\Python27\lib\site-packages\pyrabbit\api.py", line 161, in get_whoami whoami = self.http.do_call(path, 'GET')
File "C:\Python27\lib\site-packages\pyrabbit\http.py", line 112, in do_call raise HTTPError(content, resp.status, resp.reason, path, body)
pyrabbit.http.HTTPError: 404 - Object Not Found (None) (whoami) (None)'
I was never able to solve this. But, this forced me to learn what json is, I used simplejson along with httplib2 and it worked like a charm...
This might be a rabbitmq configuration problem: as it is written here: https://www.rabbitmq.com/access-control.html, "guest" user can only connect via localhost:
By default, the guest user is prohibited from connecting to the broker remotely; it can only connect over a loopback interface (i.e. localhost). This applies both to AMQP and to any other protocols enabled via plugins. Any other users you create will not (by default) be restricted in this way.
This is configured via the loopback_users item in the configuration file.
If you wish to allow the guest user to connect from a remote host, you should set the loopback_users configuration item to []. A complete >rabbitmq.config which does this would look like:
[{rabbit, [{loopback_users, []}]}].
I'm trying to write data to the system log on Windows 7 using Pythons (2.7) logging.handlers.NTEventLogHandler. This does not work as there is apparently some registry access being denied. The software will be run without any special access rights. Is there any way to make this work?
Here is the exception I get:
Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import logging
>>> from logging import handlers
>>> syslog = handlers.NTEventLogHandler("Something")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\Python27\lib\logging\handlers.py", line 917, in __init__
self._welu.AddSourceToRegistry(appname, dllname, logtype)
File "c:\Python27\lib\site-packages\win32\lib\win32evtlogutil.py", line 35, in
AddSourceToRegistry
"SYSTEM\\CurrentControlSet\\Services\\EventLog\\%s\\%s" % (eventLogType, app
Name))
pywintypes.error: (5, 'RegCreateKey', 'Access is denied.')
"Win32 Extensions for Python" is required to use sysLog on Windows. Are you sure that you have installed it? [1]
From the docs [2]:
The NTEventLogHandler class, located in the logging.handlers module, supports sending logging messages to a local Windows NT, Windows 2000 or Windows XP event log. Before you can use it, you need Mark Hammond’s Win32 extensions for Python installed.
[1] http://sourceforge.net/projects/pywin32/
[2] http://docs.python.org/2/library/logging.handlers.html
The answer in my case was to adjust the permissions in regedit for my account. In my case, logging to the Application Event Log, I had to add the Full Control permission to
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\EventLog\Application
Setting just the Read permission did not work as this was already in place with the Authorized Users ACE. Also, the permission has to remain set for each execution (it isn't just a one time setting).
Alternately, you will avoid this error if you can just run your code as Administrator since the Administrators group already has Full Control over these keys.