{"id":1442,"date":"2012-05-10T13:25:48","date_gmt":"2012-05-10T17:25:48","guid":{"rendered":"http:\/\/cd34.com\/blog\/?p=1442"},"modified":"2012-06-11T10:17:25","modified_gmt":"2012-06-11T14:17:25","slug":"importerror-cannot-import-name-urandom","status":"publish","type":"post","link":"https:\/\/cd34.com\/blog\/programming\/python\/importerror-cannot-import-name-urandom\/","title":{"rendered":"ImportError: cannot import name urandom"},"content":{"rendered":"<pre>\r\n    import os, sys, imp, types, tempfile, optparse\r\n  File \"\/usr\/lib\/python2.7\/tempfile.py\", line 34, in <module>\r\n    from random import Random as _Random\r\n  File \"\/usr\/lib\/python2.7\/random.py\", line 47, in <\/module><module>\r\n    from os import urandom as _urandom\r\nImportError: cannot import name urandom\r\n<\/module><\/pre>\n<p>You&#8217;re using a virtualenv, you&#8217;re probably on Debian or Ubuntu, and you upgraded python through apt-get.<\/p>\n<p>To fix it:<\/p>\n<pre>\r\nvirtualenv \/path\/to\/your\/virtualenvironment\r\n<\/pre>\n<div style=\"float:left;\">\n<div id=\"fb-root\"><\/div>\n<fb:like href=\"https:\/\/cd34.com\/blog\/programming\/python\/importerror-cannot-import-name-urandom\/\" width=\"250\" send=\"false\" show_faces=\"false\" layout=\"button_count\" action=\"recommend\"><\/fb:like>\n<\/div><div style=\"clear:both;\"><\/div>","protected":false},"excerpt":{"rendered":"<p>import os, sys, imp, types, tempfile, optparse File &#8220;\/usr\/lib\/python2.7\/tempfile.py&#8221;, line 34, in from random import Random as _Random File &#8220;\/usr\/lib\/python2.7\/random.py&#8221;, line 47, in from os import urandom as _urandom ImportError: cannot import name urandom You&#8217;re using a virtualenv, you&#8217;re probably on Debian or Ubuntu, and you upgraded python through apt-get. To fix it: virtualenv \/path\/to\/your\/virtualenvironment<\/p>\n<div style=\"float:left;\">\n<div id=\"fb-root\"><\/div>\n<fb:like href=\"https:\/\/cd34.com\/blog\/programming\/python\/importerror-cannot-import-name-urandom\/\" width=\"250\" send=\"false\" show_faces=\"false\" layout=\"button_count\" action=\"recommend\"><\/fb:like>\n<\/div><div style=\"clear:both;\"><\/div>","protected":false},"author":15,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[73],"class_list":["post-1442","post","type-post","status-publish","format-standard","hentry","category-python","tag-virtualenv"],"_links":{"self":[{"href":"https:\/\/cd34.com\/blog\/wp-json\/wp\/v2\/posts\/1442","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cd34.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cd34.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cd34.com\/blog\/wp-json\/wp\/v2\/users\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/cd34.com\/blog\/wp-json\/wp\/v2\/comments?post=1442"}],"version-history":[{"count":2,"href":"https:\/\/cd34.com\/blog\/wp-json\/wp\/v2\/posts\/1442\/revisions"}],"predecessor-version":[{"id":1468,"href":"https:\/\/cd34.com\/blog\/wp-json\/wp\/v2\/posts\/1442\/revisions\/1468"}],"wp:attachment":[{"href":"https:\/\/cd34.com\/blog\/wp-json\/wp\/v2\/media?parent=1442"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cd34.com\/blog\/wp-json\/wp\/v2\/categories?post=1442"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cd34.com\/blog\/wp-json\/wp\/v2\/tags?post=1442"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}