Python 3.4 is missing _ssl.pyd - python

Environment:
Ubuntu 10.04.4 LTS
Python 3.4.3
I have a working python 3.4 Flask HTTPS server running perfectly on Windows. I need to transfer this over to an existing Ubuntu 10.04.4 LTS server. I have built python 3.4 on there with no problems but when I run my web server it fails with the error:
Traceback (most recent call last):
File "./server.py", line 3, in <module>
from app import create_app
File "/opt/license-server/app/__init__.py", line 10, in <module>
from config import config
File "/opt/license-server/config.py", line 9, in <module>
class Config:
File "/opt/license-server/config.py", line 25, in Config
LDAP_TLS_VERSION = ssl.PROTOCOL_TLSv1_2
AttributeError: 'module' object has no attribute 'PROTOCOL_TLSv1_2'
I did some digging around on Windows using pyCharm to find out what is going on and it seems that PROTOCOL_TLSv1_2 is defined in _ssl.py which I believe comes from _ssl.pyd. Neither _ssl.py or _ssl.pyd exists on the Ubuntu python install which leads me to believe that I'm missing some option or something when compiling but I cannot find any reference to this on the python web site on what is missing or how to get the TLS-1.2 stuff.
Can anyone point me in the right direction please?

When you build your Python 3.4 from sources, at the end of the build you get a report saying which modules were not built. My bet is that the ssl module was not build, because your Ubuntu installation doesn't have SSL packages installed. Try:
sudo apt-get install libssl-dev openssl
then try to rebuild your Python 3.4 and see if the SSL module is built.

Related

ImportError: symbol __res_maybe_init version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference

I'm running an installation script that installs a number of different python packages. The one that is getting stuck on is psycopg2. The script attempts to install version 2.6.1. But I run into the error:
Error: could not determine PostgreSQL version from '10.10'
I figured it has something to do with the version of psycopg2 that's incompatible with postgresql version 10.10. Is this an invalid conclusion?
Assuming my conclusion of version incompatibility is correct I changed the installation version of psycopg2 to 2.7. By doing that the error above went away.
However, when I run:
python manage.py runserver 0.0.0.0:888
I get the error:
File "/home/mark/.virtualenvs/nova/lib/python3.6/site-packages/django/contrib/postgres/apps.py", line 7, in <module>
from .signals import register_hstore_handler
File "/home/mark/.virtualenvs/nova/lib/python3.6/site-packages/django/contrib/postgres/signals.py", line 1, in <module>
from psycopg2 import ProgrammingError
File "/home/mark/.virtualenvs/nova/lib/python3.6/site-packages/psycopg2/__init__.py", line 50, in <module>
from psycopg2._psycopg import ( # noqa
ImportError: /home/mark/.virtualenvs/nova/lib/python3.6/site-packages/psycopg2/.libs/./libresolv-2-c4c53def.5.so: symbol __res_maybe_init version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference
This makes me think that, maybe version 2.6.1 is probably the version that I needed to use because it's complaining about psycopg2?
How do I fix the problem such that I can run the Django development server without the above error?
update psycopg2 to 2.7.3.1/2 and this error would go away like here
https://stackoverflow.com/a/49292261/1816541
I have faced this in the past.
What I did is modify the psycopg2 version in pip (not sure what your script is using for versioning packages) to 2.7
I also verified it can work well with 2.5.9
Officially there is no backward compatibility fix https://github.com/psycopg/psycopg2/issues/594#issuecomment-331172198

wxPython import error with Windows install

I have installed Python 3.4 and wxPython Phoenix on Windows 10. I go into Eclipse and add wxPython to the external libs in my project, but when I try to import it, I get this error:
Traceback (most recent call last):
File "C:\Users\linus\workspace\MiCS 1.2\main.py", line 1, in <module>
import wx
File "C:\Python34\Lib\site-packages\wx\__init__.py", line 17, in <module>
from wx.core import *
File "C:\Python34\Lib\site-packages\wx\core.py", line 6, in <module>
from ._core import *
ImportError: DLL load failed: The specified module could not be found.
I did some searching and tinkering and still can't figure out what's causing it. It shouldn't be the msvcp or msvcr DLLs as I have Office running just fine (or is that an incorrect assumption?) Any help is appreciated. Thanks.
How did you install wxpython?
As of now, the top page of the official site has wxpython 3.0 only for python27. So, I suspect you might not have installed it properly.
If you have your python34 at C:/Python34 then, cd to C:/Python34/Scripts first so that we make sure to use the pip for this python.
According to this post (https://groups.google.com/forum/#!topic/wxpython-dev/LmGIrQyh7jc), try
pip install -U --pre -f http://wxpython.org/Phoenix/snapshot-builds/ wxPython_Phoenix
This should find the corresponding whl file for your python version and CPU architecture.
Or, you could manually download whl file at http://wxpython.org/Phoenix/snapshot-builds/
If you have 32 bit Python34, then look for ******-cp34-none-win32.whl
and simply do:
pip install path/to/the/whl/that/you/just/downloaded/wxPython_Phoenix-3.0.3.dev1839+4ecd949-cp34-none-win32.whl
After this, if you can import wx in the normal cmd then the problem should be coming from eclipse.

Custom python install location: tkinter problems

I'm using Ubuntu 14.04. While I have to retain my "main" python install as 2.7.6, I need to install 2.7.9 to be able to use ssl.SSLContext, to get Flask to deal with HTTPS requests.
However, if I just do:
sudo make install
or
sudo make altinstall
in the Python-2.7.9 directory, I ultimately get:
make: *** [libinstall] Error 1
EDIT: this appears at the end of sudo make install:
...
Compiling /usr/local/lib/python2.7/xml/sax/saxutils.py ...
Compiling /usr/local/lib/python2.7/xml/sax/xmlreader.py ...
Compiling /usr/local/lib/python2.7/xmllib.py ...
Compiling /usr/local/lib/python2.7/xmlrpclib.py ...
Compiling /usr/local/lib/python2.7/zipfile.py ...
make: *** [libinstall] Error 1
So I installed it to a custom directory by modifying the call to ./config, which did not yield the libinstall error.
However, when I try to import Tkinter into Python 2.7.9 (running from the custom directory) I obtain:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/repos/Python279/lib/python2.7/lib-tk/Tkinter.py", line 39, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named _tkinter
If I just go ahead and install the vanilla way (i.e., to a non-custom directory) and simply ignore the libinstall error I get, upon importing Tkinter:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/lib-tk/Tkinter.py", line 39, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: /usr/lib/python2.7/lib-dynload/_tkinter.so: undefined symbol: PyFPE_jbuf
Does anyone have any idea what is going on?
Following furas' suggestion, installing via the
Python 2.7 PPA maintained be Felix Krull worked spectacularly. Thanks Furas!
EDIT Some notes:
Because this PPA installs python2.7 (specifically v. 2.7.11, as of 1/29/2016), this obviated the need for a custom python install location
While the PPA website mentions that this doesn't include python-tk, provided you have installed it, python plays with it just fine (solving my problem)
First of all source code from a program must be configured, compiled, then installed. You can do this by:
./configure # Or ./config depending on the file name
make
make install
Second of all when you tried to import the module _tkinter you wanted to import the .py file which was called Tkinter.py
Try to use:
import Tkinter

Cherrypy json_out module error in Ubuntu

I am trying to get Cherrypy to output json for a project and on my Mac adding the #cherrpy.tools.json_out() decorator is working a treat but on my Ubuntu 13.04 system I get this error.
Traceback (most recent call last):
File "cherrypy.py", line 1, in <module>
import cherrypy
File "/bla/cherrypy.py", line 4, in <module>
class Root(object):
File "/bla/cherrypy.py", line 6, in Root
#cherrypy.tools.json_out()
AttributeError: 'module' object has no attribute 'tools'
The code above is a direct copy from the bottom of this page.
http://tools.cherrypy.org/wiki/JSON
If i enter a python shell then run interactive help on the module I get a similar result.
help> cherrypy
problem in cherrypy - <type 'exceptions.AttributeError'>: 'module' object has no attribute 'tools'
I have tried searching but I can't find anyone else having the same issue? (Maybe I am missing the wood for the trees?)
I have tried reinstalling the package through apt and manually from the cherrypy source all against Python 2.7
Although I am developing on Mac and Ubuntu I will be deploying on an Ubuntu server so I would like to sort this out sooner rather than later.
Your help is much appreciated
Do you use python-cherrypy from ubuntu package? It's version is 2.3.0 which does not have cherrypy.tools modules.
Install newer version (sudo pip install -U cherrypy).

Django installation has no __init__.py in django.core

I have a ubuntu lucid VPS server where I try to run my django development server.
Running python manage.py runserver gives me the following error:
Traceback (most recent call last):
File "manage.py", line 2, in <module>
from django.core.management import execute_manager
ImportError: No module named core.management
I can import django without any problem in a python shell. I looked in the django install directory and noticed there is no \__init__.py in the django/core folder. Which I beleive is the source of the problem for python to register django.core as a module.
It then looks like an installation issue. I installed django using apt-get.
FYI the django install worked perfectly on my home computer with same OS.
Any ideas?
solved.
Thank you for all the suggestions. I installed django using the tar ball as instructed in the django website.
apt-get is not a good idea to install django. I also had to manually remove the left over django folder in /usr/lib/pymodules/python2.6 after using apt-get remove.

Categories

Resources