LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-07-2010, 11:42 PM   #1
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
Python noob question


I have installed a new module for Python (pycrypto) and when I run
the following:

python -c "import Crypto.Random"

I receive the error:

ImportError: No module named OSRNG

Now in the __init__.py file is - import OSRNG (obviously the offending line)

My question is: Are you able to import simply the module required by name if it exists as part of the module you have called or is Python looking up some kind of table / list that may have not been updated with the fact that OSRNG exists?

Cheers in advance
Grail
 
Old 03-08-2010, 03:02 AM   #2
pgpython
Member
 
Registered: Dec 2005
Location: Sheffield, UK
Distribution: Gentoo
Posts: 142

Rep: Reputation: 32
Python will first look in the current working directory and then in the paths specified by sys.modules. Any modules you install should be installed in the site-packages directory of the python installation. I have never used pycrypto so I don't know what it's dependecies but it looks like your missing the OSRNG module from your python installation
 
Old 03-08-2010, 06:24 AM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Original Poster
Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
Ok ... so that was kind of what I thought, but am happy for the clarification.

The path to Random is:

/usr/lib/python3.1/site-packages/Crypto/Random

below this are the following:

random.py and __init__.py (as well as corresponding pyc files) plus the OSRNG directory

Therefore, I would assume that it should find OSRNG module which is being called from the __init__.py
of Random???

Colour me confused
 
Old 03-08-2010, 10:06 AM   #4
pgpython
Member
 
Registered: Dec 2005
Location: Sheffield, UK
Distribution: Gentoo
Posts: 142

Rep: Reputation: 32
Having a closer look at PyCrypto reveals that OSRNG is a package of PyCrypto and should be in site-packages/Crypto/Random so I don't think you have a complete install of PyCrypto. If you reinstall it using your distros pacakge manager then it should fix the issue
 
Old 03-08-2010, 07:46 PM   #5
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Original Poster
Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
Well I tried that but to no avail
Can I confirm that what we have been talking about is the same for both Python 2.X and Python 3.x?

Also, I have run some small crypto scripts with other parts of the module and these seem to work ok

Edit: It appears there were some compile issues which couldn't be seen straight away.
Thanks for the assist.

Last edited by grail; 03-11-2010 at 06:34 AM. Reason: Found solution
 
Old 01-22-2014, 08:16 AM   #6
kathar
LQ Newbie
 
Registered: Jan 2014
Posts: 1

Rep: Reputation: Disabled
Need solution for this issue

Hi Grail,

Kindly add the solution on how you fix this issue.
Currently I am facing the same with import Crypto.Random
 
Old 01-23-2014, 07:21 AM   #7
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Original Poster
Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
Hi kathar, unfortunately being so old this post is not particularly relevant anymore as both Python and Pycrypto have undergone several updates in this time.

My suggestion would be to contact the pycrypto guys, as I found them all very helpful, and they should be able to assist.

As for my solution, as mentioned I found compile issues in the pycrypto source but currently I am at a loss to remember exactly what they were (sorry)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
python noob: arg1 "must be string not tuple"? agrestic Programming 5 01-07-2009 06:03 PM
noob question Cyran Linux - Security 1 09-18-2006 12:21 AM
Python noob - running programs in the background / recieving signals form the OS crm Programming 0 09-18-2005 07:11 AM
noob with a noob question phoonerorlater Linux - Newbie 2 09-29-2004 03:43 PM
Complete noob question from a noob noob_hampster Linux - Software 2 09-04-2003 12:03 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration