{"id":907,"date":"2017-12-13T13:00:28","date_gmt":"2017-12-13T13:00:28","guid":{"rendered":"http:\/\/chewett.co.uk\/blog\/?p=907"},"modified":"2017-12-12T00:10:32","modified_gmt":"2017-12-12T00:10:32","slug":"fixing-importerror-no-module-named-winrandom","status":"publish","type":"post","link":"https:\/\/chewett.co.uk\/blog\/907\/fixing-importerror-no-module-named-winrandom\/","title":{"rendered":"Fixing ImportError: No module named &#8216;winrandom&#8217;"},"content":{"rendered":"<p>This post describes how you can fix the python error <code>No module named 'winrandom'<\/code>. This is typically found when you are using the <code>pyCrypto<\/code> or\u00a0<code>coinbase<\/code> python module.<\/p>\n<p><!--more--><\/p>\n<h2>What is the No module named &#8216;winrandom&#8217; error<\/h2>\n<p>This python error may occur whenever you try and use a module that requires the <code>winrandom<\/code> module. I found this problem occurring when I was importing the coinbase python module. This is because this includes and uses the <code>pyCrypto<\/code> module.<\/p>\n<p>The full error log of the error is copied below.<\/p>\n<pre>Traceback (most recent call last):\r\nFile \"C:\/dev\/test.py\", line 2, in &lt;module&gt;\r\nfrom coinbase.wallet.client import Client\r\nFile \"C:\\dev\\python35\\lib\\site-packages\\coinbase\\wallet\\client.py\", line 41, in &lt;module&gt;\r\nfrom Crypto.PublicKey import RSA\r\nFile \"C:\\dev\\python35\\lib\\site-packages\\Crypto\\PublicKey\\RSA.py\", line 78, in &lt;module&gt;\r\nfrom Crypto import Random\r\nFile \"C:\\dev\\python35\\lib\\site-packages\\Crypto\\Random\\__init__.py\", line 28, in &lt;module&gt;\r\nfrom Crypto.Random import OSRNG\r\nFile \"C:\\dev\\python35\\lib\\site-packages\\Crypto\\Random\\OSRNG\\__init__.py\", line 34, in &lt;module&gt;\r\nfrom Crypto.Random.OSRNG.nt import new\r\nFile \"C:\\dev\\python35\\lib\\site-packages\\Crypto\\Random\\OSRNG\\nt.py\", line 28, in &lt;module&gt;\r\nimport winrandom\r\nImportError: No module named 'winrandom'<\/pre>\n<p>This error occurs due to the way the imports works in the <code>pyCrypto<\/code> library. In the next step I will describe how we can fix it.<\/p>\n<h2>Fixing the\u00a0No module named &#8216;winrandom&#8217; error<\/h2>\n<p>To fix the no module error we need to modify one of the files used by <code>pyCrypto<\/code>. First we need to locate the directory Python3 is installed in.<\/p>\n<p>The most common location python is installed in is:<\/p>\n<pre>C:\\PythonXX\\<\/pre>\n<p>Where XX is the version number. In my case I have installed python to <code>C:\\dev\\Python35\\<\/code><\/p>\n<p>Once you have located the python directory you need to go into the <code>Lib\\site-packages\\Crypto\\Random\\OSRNG<\/code><\/p>\n<p>The most common location this will be is:<\/p>\n<pre>C:\\PythonXX\\Lib\\site-packages\\Crypto\\Random\\OSRNG<\/pre>\n<p>In my case this is: <code>C:\\dev\\Python35\\Lib\\site-packages\\Crypto\\Random\\OSRNG<\/code><\/p>\n<p>Once in this directory you need to open the <code>nt.py<\/code>\u00a0file\u00a0and find the line <code>import winrandom<\/code>.<\/p>\n<p>This line needs to be changed from:<\/p>\n<pre>import winrandom<\/pre>\n<p>to<\/p>\n<pre>from . import winrandom<\/pre>\n<p>Once this has been done your modules using <code>pyCrypto<\/code> will start working.\u00a0This resolved a relative import issue with this python module.<\/p>\n<p>If you have any questions or trouble finding where python is installed feel free to ask in the comments.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This post describes how you can fix the python error No module named &#8216;winrandom&#8217;. This is typically found when you are using the pyCrypto or\u00a0coinbase python module.<\/p>\n","protected":false},"author":1,"featured_media":910,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[3],"tags":[199,200,184,198,201],"class_list":["post-907","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-fixes","tag-coinbase","tag-pycrypto","tag-python","tag-python-3","tag-winrandom"],"wppr_data":{"cwp_meta_box_check":"No"},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2017\/12\/python_fix_winrandom_error.jpg?fit=800%2C800&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/p2toWX-eD","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":1290,"url":"https:\/\/chewett.co.uk\/blog\/1290\/fixing-no-module-named-mysqldb-in-fedora-28\/","url_meta":{"origin":907,"position":0},"title":"Fixing No module named MySQLdb in Fedora 28","author":"Chewett","date":"June 23, 2018","format":false,"excerpt":"Today I write about how you can fix the python error \"No module named MySQLdb\" in Fedora 28 Why this error occurs This can occur when you try and run a python script that imports the module MySQLdb. If this is not properly installed it will then display the error\u2026","rel":"","context":"In &quot;Fixes&quot;","block_context":{"text":"Fixes","link":"https:\/\/chewett.co.uk\/blog\/category\/fixes\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/06\/fixing_mysqldb_python2_fedora28.jpg?fit=800%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/06\/fixing_mysqldb_python2_fedora28.jpg?fit=800%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/06\/fixing_mysqldb_python2_fedora28.jpg?fit=800%2C800&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/06\/fixing_mysqldb_python2_fedora28.jpg?fit=800%2C800&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":906,"url":"https:\/\/chewett.co.uk\/blog\/906\/storing-bitcoin-price-data-raspberry-pi\/","url_meta":{"origin":907,"position":1},"title":"Storing Bitcoin price data with a Raspberry Pi","author":"Chewett","date":"December 16, 2017","format":false,"excerpt":"This post goes through the process of collecting and storing bitcoin price data using python, crontab, and a Raspberry Pi. Collecting Bitcoin Price Data using Coinbase To gather the price of bitcoin we are going to use Coinbase as our bitcoin price provider. The reason for this is they provide\u2026","rel":"","context":"In &quot;Software&quot;","block_context":{"text":"Software","link":"https:\/\/chewett.co.uk\/blog\/category\/software\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2017\/12\/storing_bitcoin_price_with_raspi.jpg?fit=800%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2017\/12\/storing_bitcoin_price_with_raspi.jpg?fit=800%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2017\/12\/storing_bitcoin_price_with_raspi.jpg?fit=800%2C800&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2017\/12\/storing_bitcoin_price_with_raspi.jpg?fit=800%2C800&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":343,"url":"https:\/\/chewett.co.uk\/blog\/343\/raspberrypivcgencmd-python-library-access-raspberry-pi-vcgencmd-command\/","url_meta":{"origin":907,"position":2},"title":"RaspberryPiVcgencmd A python library to access Raspberry Pi vcgencmd command","author":"Chewett","date":"May 31, 2017","format":false,"excerpt":"To access some of the lower level aspects of the Raspberry Pi's config you can use the built in command vcgencmd. This is a useful on the command line but to easily access it in a program you need to parse the output. I am planning to use this command\u2026","rel":"","context":"In &quot;Raspberry Pi Cluster&quot;","block_context":{"text":"Raspberry Pi Cluster","link":"https:\/\/chewett.co.uk\/blog\/category\/raspberry-pi-cluster\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2017\/05\/vcgencmd.png?fit=628%2C288&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2017\/05\/vcgencmd.png?fit=628%2C288&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2017\/05\/vcgencmd.png?fit=628%2C288&ssl=1&resize=525%2C300 1.5x"},"classes":[]},{"id":1001,"url":"https:\/\/chewett.co.uk\/blog\/1001\/raspberry-pi-cluster-node-04-configuration-files-configparser\/","url_meta":{"origin":907,"position":3},"title":"Raspberry Pi Cluster Node \u2013 04 Configuration Files with ConfigParser","author":"Chewett","date":"February 10, 2018","format":false,"excerpt":"This post builds on the\u00a0third step to create a Raspberry Pi Cluster Node\u00a0to store our configuration settings in a config file. Here we move all the configuration settings in our script into a useful .cfg file using the python ConfigParser. Why use Configuration Files? When developing a system there will\u2026","rel":"","context":"In &quot;Raspberry Pi Cluster&quot;","block_context":{"text":"Raspberry Pi Cluster","link":"https:\/\/chewett.co.uk\/blog\/category\/raspberry-pi-cluster\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/02\/rpi_cluster_04_config_parser.jpg?fit=800%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/02\/rpi_cluster_04_config_parser.jpg?fit=800%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/02\/rpi_cluster_04_config_parser.jpg?fit=800%2C800&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/02\/rpi_cluster_04_config_parser.jpg?fit=800%2C800&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":2780,"url":"https:\/\/chewett.co.uk\/blog\/2780\/raspberry-pi-cluster-node-18-raspberry-pi-temperature-monitoring\/","url_meta":{"origin":907,"position":4},"title":"Raspberry Pi Cluster Node \u2013 18 Raspberry Pi Temperature Monitoring","author":"Chewett","date":"February 20, 2021","format":false,"excerpt":"This post builds on\u00a0my previous posts in the Raspberry Pi Cluster series\u00a0by starting to log temperature with the RaspberryPiVcgencmd Python module. Installing RaspberryPiVcgencmd RaspberryPiVcgencmd is a small python module aimed to control vcgencmd and allow programmatic access to it. This can be installed with the following command. python3 -m pip\u2026","rel":"","context":"In &quot;Raspberry Pi Cluster&quot;","block_context":{"text":"Raspberry Pi Cluster","link":"https:\/\/chewett.co.uk\/blog\/category\/raspberry-pi-cluster\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2021\/02\/raspi_cluster_18_cputemperature_posticon_OUTPUT.png?fit=1200%2C628&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2021\/02\/raspi_cluster_18_cputemperature_posticon_OUTPUT.png?fit=1200%2C628&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2021\/02\/raspi_cluster_18_cputemperature_posticon_OUTPUT.png?fit=1200%2C628&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2021\/02\/raspi_cluster_18_cputemperature_posticon_OUTPUT.png?fit=1200%2C628&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2021\/02\/raspi_cluster_18_cputemperature_posticon_OUTPUT.png?fit=1200%2C628&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":2829,"url":"https:\/\/chewett.co.uk\/blog\/2829\/python-psutil-and-the-differences-between-free-and-available-memory\/","url_meta":{"origin":907,"position":5},"title":"Python Psutil and the differences between free and available memory","author":"Chewett","date":"March 13, 2021","format":false,"excerpt":"In this blog post I am talking about the difference between free and available memory in the psutil python module. Python psutil module The python psutil module is a cross platform library that allows reading various process and system metrics. In the Raspberry Pi Cluster I am using this to\u2026","rel":"","context":"In &quot;Informational&quot;","block_context":{"text":"Informational","link":"https:\/\/chewett.co.uk\/blog\/category\/informational\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2021\/03\/python_psutil_memory_posticon_OUTPUT.png?fit=1200%2C628&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2021\/03\/python_psutil_memory_posticon_OUTPUT.png?fit=1200%2C628&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2021\/03\/python_psutil_memory_posticon_OUTPUT.png?fit=1200%2C628&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2021\/03\/python_psutil_memory_posticon_OUTPUT.png?fit=1200%2C628&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2021\/03\/python_psutil_memory_posticon_OUTPUT.png?fit=1200%2C628&ssl=1&resize=1050%2C600 3x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/posts\/907","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/comments?post=907"}],"version-history":[{"count":2,"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/posts\/907\/revisions"}],"predecessor-version":[{"id":911,"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/posts\/907\/revisions\/911"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/media\/910"}],"wp:attachment":[{"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/media?parent=907"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/categories?post=907"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/tags?post=907"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}