Error while installing python setuptools for compiling pyOpenSSL - python

I want to use pyOpenSSL, which I have downloaded and tried to build, but I am having problems with setuptools.
First I have downloaded just python and used it with no success, but now I have tried with WinPython and got the same result, which is:
Traceback (most recent call last):
File "setup.py", line 11, in <module>
from setuptools import setup
File "C:\Users\User\Downloads\WinPython-32bit-2.7.6.3\python-2.7.6\lib\site-packages\setuptools\__init_
_.py", line 11, in <module>
from setuptools.extension import Extension
File "C:\Users\User\Downloads\WinPython-32bit-2.7.6.3\python-2.7.6\lib\site-packages\setuptools\extensi
on.py", line 5, in <module>
from setuptools.dist import _get_unpatched
File "C:\Users\User\Downloads\WinPython-32bit-2.7.6.3\python-2.7.6\lib\site-packages\setuptools\dist.py
", line 15, in <module>
from setuptools.compat import numeric_types, basestring
File "C:\Users\User\Downloads\WinPython-32bit-2.7.6.3\python-2.7.6\lib\site-packages\setuptools\compat.
py", line 19, in <module>
from SimpleHTTPServer import SimpleHTTPRequestHandler
File "C:\Users\User\Downloads\WinPython-32bit-2.7.6.3\python-2.7.6\lib\SimpleHTTPServer.py", line 27, i
n <module>
class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
File "C:\Users\User\Downloads\WinPython-32bit-2.7.6.3\python-2.7.6\lib\SimpleHTTPServer.py", line 208,
in SimpleHTTPRequestHandler
mimetypes.init() # try to read system mime.types
File "C:\Users\User\Downloads\WinPython-32bit-2.7.6.3\python-2.7.6\lib\mimetypes.py", line 358, in init
db.read_windows_registry()
File "C:\Users\User\Downloads\WinPython-32bit-2.7.6.3\python-2.7.6\lib\mimetypes.py", line 260, in read
_windows_registry
with _winreg.OpenKey(hkcr, subkeyname) as subkey:
TypeError: must be string without null bytes or None, not str
I have installed Python 2.7.6 with PyCharm with no success, and also tried WinPython with the same result.
I am running windows 7 x64.

Since you are facing problem in installing setuptools itself, you can download the windows binary file for setuptools from this link.
This website is a great repository of pre-compiled windows binaries for various Python modules.
If installing 64-bit Python is not a necessity, I would suggest you to install 32-bit version of Python and other modules.

This is related to a bug in Python 2.7.6, to do with Windows Registry corruption.
Some programs (wrongly) write a terminating null to registry entries and this screws up setuptools. Updating Python fixes the issue.
See This blog post

Related

python-docx package is giving errors in script

I installed this python package using pip that was compatible with Python 2.7, in a windows machine. I tried newer versions of the python-docx but those ones did not download properly. Only version 0.8.7 installed successfully and so I am using it right now. I installed it using:
pip install python-docx==0.8.7
But I think it installed a 32 bit version of this package and I am using a 64 bit machine. I know this because while I tried to run my python program using this package I got the error:
Traceback (most recent call last):
File "C:/projects/engine_script/Tools/subprocess_module/create_doc.py", line 2, in <module>
from docx import Document
File "C:\Python27\lib\site-packages\docx\__init__.py", line 3, in <module>
from docx.api import Document # noqa
File "C:\Python27\lib\site-packages\docx\api.py", line 14, in <module>
from docx.package import Package
File "C:\Python27\lib\site-packages\docx\package.py", line 11, in <module>
from docx.opc.package import OpcPackage
File "C:\Python27\lib\site-packages\docx\opc\package.py", line 12, in <module>
from .part import PartFactory
File "C:\Python27\lib\site-packages\docx\opc\part.py", line 12, in <module>
from .oxml import serialize_part_xml
File "C:\Python27\lib\site-packages\docx\opc\oxml.py", line 12, in <module>
from lxml import etree
ImportError: DLL load failed: %1 is not a valid Win32 application.
This is where the package got downloaded to: C:\Python27\Lib\site-packages\lxml-3.3.5-py2.7-win32.egg
Anyone have the link to the 64 bit version (win_amd64.whl) of this package? I tried searching in this link(https://www.lfd.uci.edu/~gohlke/pythonlibs/) but could not find the package I was looking for. I even have the latest lxml package and the package is still not working as the script shows errors.

Anaconda navigator not launching, not even through terminal

I installed the latest version of Anaconda on my Windows 10. After installing i tried to launch it but it wouldn't launch even after trying several times. I also tried to launch the jupyter notebook and spider shortcut that was created but even that didn't work. So I tried to run it using the terminal and this is the error I recieved:
UserWarning: Distutils was imported before Setuptools. This usage is discouraged and may exhibit undesirable behaviors or errors. Please use Setuptools' objects directly or at least import Setuptools first.
warnings.warn(
Traceback (most recent call last):
File "C:\Users\capta\anaconda3\Scripts\jupyter-notebook-script.py", line 6, in <module>
from notebook.notebookapp import main
File "C:\Users\capta\anaconda3\lib\site-packages\notebook\notebookapp.py", line 49, in <module>
from zmq.eventloop import ioloop
File "C:\Users\capta\anaconda3\lib\site-packages\zmq\__init__.py", line 47, in <module>
from zmq import backend
File "C:\Users\capta\anaconda3\lib\site-packages\zmq\backend\__init__.py", line 40, in <module>
reraise(*exc_info)
File "C:\Users\capta\anaconda3\lib\site-packages\zmq\utils\sixcerpt.py", line 34, in reraise
raise value
File "C:\Users\capta\anaconda3\lib\site-packages\zmq\backend\__init__.py", line 27, in <module>
_ns = select_backend(first)
File "C:\Users\capta\anaconda3\lib\site-packages\zmq\backend\select.py", line 28, in select_backend
mod = __import__(name, fromlist=public_api)
File "C:\Users\capta\anaconda3\lib\site-packages\zmq\backend\cython\__init__.py", line 6, in <module>
from . import (constants, error, message, context,
ImportError: DLL load failed while importing error: The specified module could not be found.
I also encountered this problem after I uninstalled the Microsoft Visual Studio C++ redistributable. It fixed (DLL error) after I installed Visual Studio 2015, 2017, and 2019.
You can find it on The latest supported Visual C++ downloads

Python 2.7 won't load any modules I installed. Will only load native modules that come with Python 2.7

Note: Please don't comment here that Python 2.7 is depreciated. I already know this. I need to get this working first before migrating to 3.x.
On Windows 10, I had installed (and running correctly) both Python 2.7 and Python 3.7. Since I only needed Python 2.7, I uninstalled Python 3.7 (and manually deleted respective packages installed under .\Python37*) as well as the virtual environment directory below. I have no idea if that virtual environment was associated with Python 2.7 or Python 3.7:
C:\Users\MKANET\Envs\MKA.NETT
After I rebooted, to my horror, every time I run a Python 2.7 script, I get a whole bunch of ambiguous traceback errors when trying to import modules I had installed with PIP (for Python 2.7). However, I don't have issues importing the modules like sys, json (packages that come preinstalled with Python 2.7).
When executing script below from Windows command-line:
& C:/Users/MKANET/AppData/Local/Programs/Python/python27/python.exe c:/Users/MKANET/OneDrive/Dev/Projects/Python/test2.py
...I get a bunch of ambiguous traceback errors:.
Traceback (most recent call last):
File "c:/Users/MKANET/OneDrive/Dev/Projects/Python/test2.py", line 3, in <module>
from pypsexec.client import Client
File "C:\Users\MKANET\AppData\Local\Programs\Python\python27\lib\site-packages\pypsexec\client.py", line 8, in <module>
from smbprotocol.connection import Connection, NtStatus
File "C:\Users\MKANET\AppData\Local\Programs\Python\python27\lib\site-packages\smbprotocol\connection.py", line 33, in <module>
from cryptography.hazmat.primitives.ciphers import (
File "C:\Users\MKANET\AppData\Local\Programs\Python\python27\lib\site-packages\cryptography\hazmat\primitives\ciphers\aead.py", line 10, in <module>
from cryptography.hazmat.backends.openssl import aead
File "C:\Users\MKANET\AppData\Local\Programs\Python\python27\lib\site-packages\cryptography\hazmat\backends\openssl\__init__.py", line 7, in <module>
from cryptography.hazmat.backends.openssl.backend import backend
File "C:\Users\MKANET\AppData\Local\Programs\Python\python27\lib\site-packages\cryptography\hazmat\backends\openssl\backend.py", line 16, in <module>
from cryptography import utils, x509
File "C:\Users\MKANET\AppData\Local\Programs\Python\python27\lib\site-packages\cryptography\x509\__init__.py", line 8, in <module>
from cryptography.x509.base import (
File "C:\Users\MKANET\AppData\Local\Programs\Python\python27\lib\site-packages\cryptography\x509\base.py", line 18, in <module>
from cryptography.x509.extensions import Extension, ExtensionType
File "C:\Users\MKANET\AppData\Local\Programs\Python\python27\lib\site-packages\cryptography\x509\extensions.py", line 26, in <module>
from cryptography.x509.general_name import GeneralName, IPAddress, OtherName
File "C:\Users\MKANET\AppData\Local\Programs\Python\python27\lib\site-packages\cryptography\x509\general_name.py", line 10, in <module>
from email.utils import parseaddr
File "c:\Users\MKANET\OneDrive\Dev\Projects\Python\email.py", line 11, in <module>
obj = win32com.client.Dispatch("Outlook.Application")
File "C:\Users\MKANET\AppData\Local\Programs\Python\python27\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch
dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
File "C:\Users\MKANET\AppData\Local\Programs\Python\python27\lib\site-packages\win32com\client\dynamic.py", line 114, in _GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
File "C:\Users\MKANET\AppData\Local\Programs\Python\python27\lib\site-packages\win32com\client\dynamic.py", line 91, in _GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch)
pywintypes.com_error: (-2147221005, 'Invalid class string', None, None)
UPDATE HUGE CLUE:
This is ONLY happens when executing scripts in the below folder:
C:\Users\Michael\OneDrive\Dev\Projects\Python
If I execute a script in any other folder on my C: Drive, modules load perfectly without errors. I don't know what's different about this folder that causes my modules not load. Maybe, there's a file in this folder that causing this?
Since this issue was limited only to scripts inside the below directory:
C:\Users\Michael\OneDrive\Dev\Projects\Python
I was able to narrow the issue down to a file called, email.py. If I tried to import a module for example, requests; for some odd reason an email.pyc would get created; followed by the import module errors. All I did was rename email.py to mail.py.. and, this whole issue finally stopped.
I have no idea why Python 2.7 is sensitive to that file name, but changing it to something else resolved the issue for me. Maybe, someone could comment on why the file name breaks things; especially when I had a __init__.py in the same directory to import another module.

why is my spyder IDE no longer opening

I just closed my spyder IDE on win7 64bit 64bit python2.7 after a long session.
during that last session, I had also installed a couple of new libraries via conda install. maybe that threw things off?
now when I try to start spyder again, the spyder splash screen appears briefly but then spyder doesn't open. if I try to start spyder from the command line, I get the following error:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\jlarsch>conda install spyder
Warning: could not import binstar_client (A 0.7-series setuptools cannot be inst
alled with distribute. Found one at c:\users\jlarsch\appdata\local\continuum\ana
conda\lib\site-packages\setuptools-20.7.0-py2.7.egg)Fetching package metadata: .
...
Solving package specifications: .........
# All requested packages already installed.
# packages in environment at C:\Users\jlarsch\AppData\Local\Continuum\Anaconda:
#
spyder 2.3.9 py27_0
C:\Users\jlarsch>spyder
Traceback (most recent call last):
File "C:\Users\jlarsch\AppData\Local\Continuum\Anaconda\Scripts\spyder-script.
py", line 2, in <module>
start_app.main()
File "C:\Users\jlarsch\AppData\Local\Continuum\Anaconda\lib\site-packages\spyd
erlib\start_app.py", line 114, in main
from spyderlib import spyder
File "C:\Users\jlarsch\AppData\Local\Continuum\Anaconda\lib\site-packages\spyd
erlib\spyder.py", line 137, in <module>
from spyderlib.ipythonconfig import IPYTHON_QT_INSTALLED
File "C:\Users\jlarsch\AppData\Local\Continuum\Anaconda\lib\site-packages\spyd
erlib\ipythonconfig.py", line 24, in <module>
required_version=IPYTHON_REQVER)
File "C:\Users\jlarsch\AppData\Local\Continuum\Anaconda\lib\site-packages\spyd
erlib\dependencies.py", line 70, in add
installed_version)]
File "C:\Users\jlarsch\AppData\Local\Continuum\Anaconda\lib\site-packages\spyd
erlib\dependencies.py", line 32, in __init__
self.installed_version = programs.get_module_version(modname)
File "C:\Users\jlarsch\AppData\Local\Continuum\Anaconda\lib\site-packages\spyd
erlib\utils\programs.py", line 238, in get_module_version
mod = __import__(module_name)
File "C:\Users\jlarsch\AppData\Local\Continuum\Anaconda\lib\site-packages\IPyt
hon\__init__.py", line 48, in <module>
from .terminal.embed import embed
File "C:\Users\jlarsch\AppData\Local\Continuum\Anaconda\lib\site-packages\IPyt
hon\terminal\embed.py", line 16, in <module>
from IPython.core.interactiveshell import DummyMod
File "C:\Users\jlarsch\AppData\Local\Continuum\Anaconda\lib\site-packages\IPyt
hon\core\interactiveshell.py", line 31, in <module>
from pickleshare import PickleShareDB
File "C:\Users\jlarsch\AppData\Local\Continuum\Anaconda\lib\site-packages\pick
leshare.py", line 41, in <module>
from path import path as Path
File "C:\Users\jlarsch\AppData\Local\Continuum\Anaconda\lib\site-packages\path
.py", line 126, in <module>
except pkg_resources.DistributionNotFound:
NameError: name 'pkg_resources' is not defined
seems related to this issue but I don't understand how I might be able to fix this on windows?
try this download setuptools from here and install.

Problems getting twill installed and working in python 2.7

I installed twill by using pip, and another try using easy_install, I want to play around with it in Powershell. Following this page - http://twill.idyll.org/ I wanted to play around with it.
To start using twill, install it and then type twill-sh. At the prompt type:
go http://www.slashdot.org/
show
showforms
showhistory
When I type twill-sh it doesn't work. I have typed it in power shell, tried it after loading python, and tried it after using import twill and trying it. I only get errors.
Traceback (most recent call last):
File "C:\Python27\Scripts\twill-sh-script.py", line 9, in <module>
load_entry_point('twill==1.8.0', 'console_scripts', 'twill-sh')()
File "build\bdist.win32\egg\pkg_resources.py", line 356, in load_entry_point
File "build\bdist.win32\egg\pkg_resources.py", line 2439, in load_entry_point
File "build\bdist.win32\egg\pkg_resources.py", line 2155, in load
File "C:\Python27\lib\site-packages\twill\__init__.py", line 52, in <module>
from shell import TwillCommandLoop
File "C:\Python27\lib\site-packages\twill\shell.py", line 9, in <module>
from twill import commands, parse, __version__
File "C:\Python27\lib\site-packages\twill\commands.py", line 7, in <module>
from lxml import html
How do I just load modules so I can play with them without writing scripts?
I had the same problem. Further down the log I found the following:
File "C:\Anaconda\lib\site-packages\lxml\cssselect.py", line 18, in <module> raise ImportError('cssselect seems not to be installed. '
ImportError: cssselect seems not to be installed. See http://packages.python.org/cssselect/
Which I fixed by installing package cssselect (using conda as I have an Anaconda installation, pip should do the same).
conda install cssselect

Categories

Resources