from packaging import version as pack_version ImportError: No module named packaging

2017-10-27 Thread David Gabriel
Dears,

I am running a python code that generates for me this error :

from packaging import version as pack_version
ImportError: No module named packaging

I googled it and I have found so many suggestions regarding updating 'pip'
and installing python-setuptools but all of these did not fix this issue.

Do you have any idea how can I solve this problem.
Thanks in advance.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: from packaging import version as pack_version ImportError: No module named packaging

2017-10-28 Thread David Gabriel
Thanks so Lutz much for your reply.
I am using python2.7 and I am running this code in an Openstack instance.
I will apply your recommandation and let you know about the result ...

Kind regards.

2017-10-27 16:13 GMT+02:00 Lutz Horn :

> On Fri, Oct 27, 2017 at 03:56:39PM +0200, David Gabriel wrote:
> > from packaging import version as pack_version
> > ImportError: No module named packaging
> >
> > I googled it and I have found so many suggestions regarding updating
> > 'pip' and installing python-setuptools but all of these did not fix
> > this issue.
>
> So many questions:
>
> * What is your Python version?
> * Do you use virtualenv?
> * How?
> * Did you install packaging in this virtualenv?
>
> Just one example of making this work:
>
> $ mkdir /tmp/pack
> $ cd /tmp/pack
> $ virtualenv -p $(which python3.5) .
> Running virtualenv with interpreter /usr/bin/python3.5
> Using base prefix '/usr'
> New python executable in /tmp/pack/bin/python3.5
> Also creating executable in /tmp/pack/bin/python
> Installing setuptools, pkg_resources, pip, wheel...done.
> $ source bin/activate
> $ pip3 install packaging
> Collecting packaging
>   Using cached packaging-16.8-py2.py3-none-any.whl
> Collecting six (from packaging)
>   Using cached six-1.11.0-py2.py3-none-any.whl
> Collecting pyparsing (from packaging)
>   Using cached pyparsing-2.2.0-py2.py3-none-any.whl
> Installing collected packages: six, pyparsing, packaging
> Successfully installed packaging-16.8 pyparsing-2.2.0 six-1.11.0
> $ python3.5
> Python 3.5.2 (default, Sep 14 2017, 22:51:06)
> [GCC 5.4.0 20160609] on linux
> Type "help", "copyright", "credits" or "license" for more
> information.
> >>> from packaging import version as pack_version
> >>>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: from packaging import version as pack_version ImportError: No module named packaging

2017-10-28 Thread David Gabriel
I forget to precise that I am using pycharm.
And this issue is reproducible also using command line to run the code.

Best regards

2017-10-28 14:31 GMT+02:00 David Gabriel :

> Thanks so Lutz much for your reply.
> I am using python2.7 and I am running this code in an Openstack instance.
> I will apply your recommandation and let you know about the result ...
>
> Kind regards.
>
> 2017-10-27 16:13 GMT+02:00 Lutz Horn :
>
>> On Fri, Oct 27, 2017 at 03:56:39PM +0200, David Gabriel wrote:
>> > from packaging import version as pack_version
>> > ImportError: No module named packaging
>> >
>> > I googled it and I have found so many suggestions regarding updating
>> > 'pip' and installing python-setuptools but all of these did not fix
>> > this issue.
>>
>> So many questions:
>>
>> * What is your Python version?
>> * Do you use virtualenv?
>> * How?
>> * Did you install packaging in this virtualenv?
>>
>> Just one example of making this work:
>>
>> $ mkdir /tmp/pack
>> $ cd /tmp/pack
>> $ virtualenv -p $(which python3.5) .
>> Running virtualenv with interpreter /usr/bin/python3.5
>> Using base prefix '/usr'
>> New python executable in /tmp/pack/bin/python3.5
>> Also creating executable in /tmp/pack/bin/python
>> Installing setuptools, pkg_resources, pip, wheel...done.
>> $ source bin/activate
>> $ pip3 install packaging
>> Collecting packaging
>>   Using cached packaging-16.8-py2.py3-none-any.whl
>> Collecting six (from packaging)
>>   Using cached six-1.11.0-py2.py3-none-any.whl
>> Collecting pyparsing (from packaging)
>>   Using cached pyparsing-2.2.0-py2.py3-none-any.whl
>> Installing collected packages: six, pyparsing, packaging
>> Successfully installed packaging-16.8 pyparsing-2.2.0 six-1.11.0
>> $ python3.5
>> Python 3.5.2 (default, Sep 14 2017, 22:51:06)
>> [GCC 5.4.0 20160609] on linux
>> Type "help", "copyright", "credits" or "license" for more
>> information.
>> >>> from packaging import version as pack_version
>> >>>
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: from packaging import version as pack_version ImportError: No module named packaging

2017-10-30 Thread David Gabriel
Dears,

When I run this command I got this error message:

ubuntu@orchestrateur:/tmp/pack$ virtualenv -p $(which python3.5) .
Running virtualenv with interpreter /usr/local/sbin/.
Traceback (most recent call last):
  File "/usr/bin/virtualenv", line 3, in 
virtualenv.main()
  File "/usr/lib/python2.7/dist-packages/virtualenv.py", line 784, in main
popen = subprocess.Popen([interpreter, file] + sys.argv[1:], env=env)
  File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
raise child_exception
OSError: [Errno 13] Permission denied


This error is also reproducible using sudo.
Please advise how to fix it.

Thanks in advance.
Best regards


2017-10-28 14:33 GMT+02:00 David Gabriel :

> I forget to precise that I am using pycharm.
> And this issue is reproducible also using command line to run the code.
>
> Best regards
>
> 2017-10-28 14:31 GMT+02:00 David Gabriel :
>
>> Thanks so Lutz much for your reply.
>> I am using python2.7 and I am running this code in an Openstack instance.
>> I will apply your recommandation and let you know about the result ...
>>
>> Kind regards.
>>
>> 2017-10-27 16:13 GMT+02:00 Lutz Horn :
>>
>>> On Fri, Oct 27, 2017 at 03:56:39PM +0200, David Gabriel wrote:
>>> > from packaging import version as pack_version
>>> > ImportError: No module named packaging
>>> >
>>> > I googled it and I have found so many suggestions regarding updating
>>> > 'pip' and installing python-setuptools but all of these did not fix
>>> > this issue.
>>>
>>> So many questions:
>>>
>>> * What is your Python version?
>>> * Do you use virtualenv?
>>> * How?
>>> * Did you install packaging in this virtualenv?
>>>
>>> Just one example of making this work:
>>>
>>> $ mkdir /tmp/pack
>>> $ cd /tmp/pack
>>> $ virtualenv -p $(which python3.5) .
>>> Running virtualenv with interpreter /usr/bin/python3.5
>>> Using base prefix '/usr'
>>> New python executable in /tmp/pack/bin/python3.5
>>> Also creating executable in /tmp/pack/bin/python
>>> Installing setuptools, pkg_resources, pip, wheel...done.
>>> $ source bin/activate
>>> $ pip3 install packaging
>>> Collecting packaging
>>>   Using cached packaging-16.8-py2.py3-none-any.whl
>>> Collecting six (from packaging)
>>>   Using cached six-1.11.0-py2.py3-none-any.whl
>>> Collecting pyparsing (from packaging)
>>>   Using cached pyparsing-2.2.0-py2.py3-none-any.whl
>>> Installing collected packages: six, pyparsing, packaging
>>> Successfully installed packaging-16.8 pyparsing-2.2.0 six-1.11.0
>>> $ python3.5
>>> Python 3.5.2 (default, Sep 14 2017, 22:51:06)
>>> [GCC 5.4.0 20160609] on linux
>>> Type "help", "copyright", "credits" or "license" for more
>>> information.
>>> >>> from packaging import version as pack_version
>>> >>>
>>> --
>>> https://mail.python.org/mailman/listinfo/python-list
>>>
>>
>>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


parallel (concurrent) eventlet

2016-01-18 Thread David Gabriel
nal.signal(signal.SIGTERM,commenceShutdown)
# signal.signal(signal.SIGINT,commenceShutdown)
 try:
   ldap_url =
ldapurl.LDAPUrl('ldap://localhost/dc=example,dc=org?*?sub?(objectClass=*)?bindname=cn=admin%2cdc=test%2cdc=com,X-BINDPW=myPassword')#ldapurl.LDAPUrl(sys.argv[1])
 #  ldap_url = ldapurl.LDAPUrl(link)
   database_path = 'test.com'#sys.argv[2]
 #  database_path = pathName
 except IndexError,e:
   print 'Usage: syncrepl-client.py  '
   sys.exit(1)
 except ValueError,e:
   print 'Error parsing command-line arguments:',str(e)
   sys.exit(1)

 while watcher_running:
 print 'Connecting to LDAP server now...'
 # Prepare the LDAP server connection (triggers the connection as
well)
 ldap_connection =
SyncReplConsumer(database_path,ldap_url.initializeUrl())

 # Now we login to the LDAP server
 try:
 ldap_connection.simple_bind_s(ldap_url.who,ldap_url.cred)
 except ldap.INVALID_CREDENTIALS, e:
 print 'Login to LDAP server failed: ', str(e)
 sys.exit(1)
 except ldap.SERVER_DOWN:
 continue

 # Commence the syncing
 print 'Commencing sync process'
 ldap_search = ldap_connection.syncrepl_search(
   ldap_url.dn or '',
   ldap_url.scope or ldap.SCOPE_SUBTREE,
   mode = 'refreshAndPersist',
   filterstr = ldap_url.filterstr or '(objectClass=*)')
 print 'After syncrepl_search.'
 try:
 while ldap_connection.syncrepl_poll( all = 1, msgid =
ldap_search):
  pass
 except KeyboardInterrupt:
  # User asked to exit
 commenceShutdown()
 pass
 except Exception, e:
  # Handle any exception
 if watcher_running:
 print 'Encountered a problem, going to retry. Error:',
str(e)
 eventlet.sleep(5)
 pass

# Define a function for the 2nd thread
def print_time(ThreadName):
 count = 0
 delay = 3
 while 1:#count < 5:
 count += 1
 print "%s: %s" % (ThreadName, time.ctime(time.time()) )
 eventlet.sleep(delay)



print 'Before call threads'

evt1 = eventlet.spawn(mainOfSyncrepl, "Thread-1",)
evt2 = eventlet.spawn(print_time, "Thread-2",)
evt3 = eventlet.spawn(print_time, "Thread-3",)

print 'After call threads'

evt1.wait()
evt2.wait()
evt3.wait()

print 'After wait'



2016-01-12 7:20 GMT-08:00 Ned Batchelder :

> David,
>
> We aren't going to be able to debug code that we can't see.  Please post a
> link to the *actual* code that you are running.
>
> --Ned.
>
>
> On 1/12/16 7:00 AM, David Gabriel wrote:
>
> Dears
>
> For more details, I am using this code
> <https://github.com/rbarrois/python-ldap/blob/master/Demo/pyasn1/syncrepl.py>in
> order to ensure the updates from my data base.
> However, when I create an eventlet basing on this code, my program is
> blocked there and is not running other eventlets !!!
> Please advise me how to fix this issue ?
>
> Thanks in advance.
> Regards
>
> 2016-01-11 7:29 GMT-08:00 David Gabriel :
>
>> Thanks so much John
>> In fact your proposal works fine for this simple example but when I use
>> it for a complex code (a data base client that receives all updates from
>> the db), my program is continously running this db client and not other
>> programs.
>>
>> Any suggestions
>> Thanks in advance
>> regards
>>
>> 2016-01-11 5:50 GMT-08:00 John Eskew < 
>> [email protected]>:
>>
>>> Add this line below your imports:
>>>
>>> eventlet.monkey_patch()
>>>
>>> Here's why that line should fix things:
>>>
>>> http://eventlet.net/doc/patching.html#greening-the-world
>>>
>>> On Mon, Jan 11, 2016 at 6:27 AM, David Gabriel < 
>>> [email protected]> wrote:
>>>
>>>> Dears,
>>>> It is the first time I am developping with python and I want to execute
>>>> parallel threads using eventlet.When I run the below code, only one thread
>>>> is executed and not both.Please could you tell me how to fix this issue ?
>>>> Please advise me how to ensure a concurrent behavior between evt1 and
>>>> evt2.
>>>>
>>>> import eventlet
>>>> import time
>>>>
>>>> def print_time(ThreadName):
>>>> count = 0
>>>> delay = 3
>>>> while 1:#count < 5:
>>>> count += 1

Re: parallel (concurrent) eventlet

2016-01-18 Thread David Gabriel
Dears,

Let me add one more detail: When I add these two lines to check whether my
modules are monkey_patched or not I get *False* as a result.
I think it is strange to get this result since I patched my modules at the
beginning using: eventlet.monkey_patch() as detailed here
<http://eventlet.net/doc/patching.html#import-green>.

print "*is_monkey_patched(ldap.syncrepl) : %s*" %
eventlet.patcher.is_monkey_patched('ldap.syncrepl')
print "*is_monkey_patched(ldap.ldapobject) : %s*" %
eventlet.patcher.is_monkey_patched('ldap.ldapobject')


Please advise me how to fix this issue.
Kind regards.


2016-01-18 12:03 GMT+01:00 David Gabriel :

> Dears,
>
> I have an issue when I use eventlet Api to create parallel threads.
> In fact, when I run the below code, only the program dealing with the
> synchronozation with ldap data base is working and is continuously blocking
> the others to run.
> But, when I use the 'thread' Api the program is working fine without any
> blocking issue. However, I can not use thread Api and I must to use
> eventlet.
> So I am wondering how to get the thread Api behavior using the eventlet
> Api ?
>
> Could you please inform me how to fix this issue ?
>
> Kindly find below my code.
> But you need some configurations regarding ldap server/client.
>
>
> #!/usr/bin/python
> # -*- coding: utf-8 -*-
> """
> This script implements a syncrepl consumer which syncs data from an
> OpenLDAP
> server to a local (shelve) database.
> Notes:
> The bound user needs read access to the attributes entryDN and entryCSN.
> This needs the following software:
> Python
> pyasn1 0.1.4+
> pyasn1-modules
> python-ldap 2.4.10+
> """
>
> # Import the python-ldap modules
> import ldap,ldapurl
> # Import specific classes from python-ldap
> from ldap.ldapobject import ReconnectLDAPObject
> from ldap.syncrepl import SyncreplConsumer
>
> # Import modules from Python standard lib
> import shelve,signal,time,sys,logging
> import eventlet
> #import thread
> eventlet.monkey_patch()
>
> # Global state
> watcher_running = True
> ldap_connection = False
>
>
>
> class SyncReplConsumer(ReconnectLDAPObject,SyncreplConsumer):
> """
> Syncrepl Consumer interface
> """
> def __init__(self,db_path,*args,**kwargs):
> # Initialise the LDAP Connection first
> ldap.ldapobject.ReconnectLDAPObject.__init__(self, *args, **kwargs)
> # Now prepare the data store
> self.__data = shelve.open(db_path, 'c')
> # We need this for later internal use
> self.__presentUUIDs = dict()
>
> def __del__(self):
> # Close the data store properly to avoid corruption
> self.__data.close()
>
> def syncrepl_get_cookie(self):
> if 'cookie' in self.__data:
> return self.__data['cookie']
>
> def syncrepl_set_cookie(self,cookie):
> self.__data['cookie'] = cookie
>
> def syncrepl_entry(self,dn,attributes,uuid):
>
> # First we determine the type of change we have here (and store
> away the previous data for later if needed)
> previous_attributes = dict()
> if uuid in self.__data:
> change_type = 'modify'
> previous_attributes = self.__data[uuid]
> else:
> change_type = 'add'
> # Now we store our knowledge of the existence of this entry
> (including the DN as an attribute for convenience)
> attributes['dn'] = dn
> self.__data[uuid] = attributes
> # Debugging
> print 'Detected', change_type, 'of entry:', dn
> # If we have a cookie then this is not our first time being run,
> so it must be a change
> if 'ldap_cookie' in self.__data:
> self.perform_application_sync(dn, attributes,
> previous_attributes)
>
> def syncrepl_delete(self,uuids):
> # Make sure we know about the UUID being deleted, just in case...
> uuids = [uuid for uuid in uuids if uuid in self.__data]
> # Delete all the UUID values we know of
> for uuid in uuids:
> print 'Detected deletion of entry:', self.__data[uuid]['dn']
> del self.__data[uuid]
>
> def syncrepl_present(self,uuids,refreshDeletes=False):
> # If we have not been given any UUID values, then we have recieved
> all the present controls...
> if uuids is None:
> # We only do things if refreshDeletes is false as the syncre