py2exe, paramiko error, ImportError - python

I am programming server-client App using python.
I need to run client side App on windows so I tried to compile script to exe with py2exe.
In head of client app:
import paramiko
import threading
import subprocess
so in setup I import paramiko
from distutils.core import setup
import py2exe, os, paramiko
setup(console=['client.py'])
when I tried to run compiled file:
Traceback (most recent call last): File "client.py", line 3, in
File "paramiko__init__.pyc", line 30, in
File "paramiko\transport.pyc", line 32, in
s♥ File "cryptography\hazmat\backends__init__.pyc", line 7, in
File "pkg_resources__init__.pyc", line 68, in
☻☺t File "pkg_resources\extern__init__.pyc", line 60, in load_module
ImportError: The 'packaging' package is required; normally this is
bundled with this package so if you get this warning, consult the
packager of your distribution.
Does anyone have a solution?

Try running pip install packaging and recompiling.

Related

Unable to run AWS CLI: ImportError: cannot import name 'HTTPClientError'

I recently tried to install some Python Packages (Superset, Bonobo amongst others) after which my AWS cli stopped working with the below issue:
user#ubuntu-machine:~$ aws --version
Traceback (most recent call last):
File "/home/user/.local/bin/aws", line 27, in <module>
sys.exit(main())
File "/home/user/.local/bin/aws", line 23, in main
return awscli.clidriver.main()
File "/home/user/.local/lib/python3.6/site-packages/awscli/clidriver.py", line 58, in main
driver = create_clidriver()
File "/home/user/.local/lib/python3.6/site-packages/awscli/clidriver.py", line 68, in create_clidriver
event_hooks=session.get_component('event_emitter'))
File "/home/user/.local/lib/python3.6/site-packages/awscli/plugin.py", line 44, in load_plugins
modules = _import_plugins(plugin_mapping)
File "/home/user/.local/lib/python3.6/site-packages/awscli/plugin.py", line 61, in _import_plugins
module = __import__(path, fromlist=[module])
File "/home/user/.local/lib/python3.6/site-packages/awscli/handlers.py", line 20, in <module>
from awscli.paramfile import register_uri_param_handler
File "/home/user/.local/lib/python3.6/site-packages/awscli/paramfile.py", line 18, in <module>
from botocore.httpsession import URLLib3Session
File "/home/user/.local/lib/python3.6/site-packages/botocore/httpsession.py", line 24, in <module>
from botocore.exceptions import (
ImportError: cannot import name 'HTTPClientError'
Inorder to restore it I've tried un-installing all packages mentioned in What is the easiest way to remove all packages installed by pip?, and only reinstalled awscli. Still I run into the same issue.
Did you uninstall botocore as well before you uninstall and reinstall the aws cli? Sometime you can get in this situation as when you install other packages it relies on different version of botocore and conflict with the one that aws cli needs. In these situations I think you want to use python virtual environment for your project to keep your project dependencies isolate from the global python environment which is where aws cli botocore resides.

ImportError: cannot import name chardet

Hi i have written a python scraper in which i am importing requests and Beautiful soup module . I am using python2.7 .
I am crating Windows executable (.exe) from my Python script using py2exe module.
For that i have created setup.py as following :
from distutils.core import setup
import py2exe
import requests
packages = [
'requests',
'requests.packages',
'requests.packages.chardet',
'requests.packages.urllib3',
'requests.packages.urllib3.packages',
'requests.packages.urllib3.contrib',
'requests.packages.urllib3.util',
'requests.packages.urllib3.packages.ssl_match_hostname',
]
setup(
console=['CompanyScraper-1.6.py']
)
I have created .exe file by running command "python setup.py py2exe".
But while running the .exe file on window it throwing following error:
Traceback (most recent call last):
File "CompanyScraper-1.6.py", line 13, in <module>
File "requests\__init__.pyc", line 58, in <module>
File "requests\utils.pyc", line 26, in <module>
File "requests\compat.pyc", line 7, in <module>
ImportError: cannot import name chardet
i could not undaerstand why this chardet import error though i have included package into setup.py
Thanks you for looking into my issue.
As you can see from the traceback -
Traceback (most recent call last):
File "CompanyScraper-1.6.py", line 13, in <module>
File "requests\__init__.pyc", line 58, in <module>
File "requests\utils.pyc", line 26, in <module>
File "requests\compat.pyc", line 7, in <module>
ImportError: cannot import name chardet
You have a requests directory with a __init__.py . This is masking the requests package from the library , so when you try to import chardet or any such thing from requests library , it tries to search for it in this local package, and not the library one.
The best solution for this would be to rename the directory and your local package from requests to something else, so that the name does not conflict with any library packages.

py2neo offline install failing

I'm trying to install py2neo on an offline machine. I can't use pip because I'm not connected to the internet. I'm trying to install py2neo-2.0.3 with python2.7.9 on redhat. When I run python setup.py install I get ImportError: cannot import name HTTPSConnection.
Traceback (most recent call last):
File "setup.py", line 29, in <module>
from py2neo import __author__, __email__, __license__, __package__, __version__
File "usr/lib/py2neo-2.0.3/py2neo/__init__.py" line 27, in <module>
from py2neo.core import *
File "usr/lib/py2neo-2.0.3/py2neo/core.py", line 28, in <module>
from py2neo.env import NEO4J_AUTH_TOKEN, NEO4J_URI
File "usr/lib/py2neo-2.0.3/py2neo/env.py", line 21, in <module>
from py2neo.packages.httpstream.packages.urimagic import URI
File "usr/lib/py2neo-2.0.3/py2neo/packages/httpstream/__init__.py", line 32, in <module>
from .http import *
File "usr/lib/py2neo-2.0.3/py2neo/packages/httpstream/http.py", line 31, in <module>
from httplib import (BadStatusLine, CannotSendRequest,
ImportError: cannot import name HTTPSConnection
I've tried installing httpstream but that didn't fix the import error.
HTTPSConnection should come with the standard library and isn't part of py2neo itself:
https://docs.python.org/2/library/httplib.html#httplib.HTTPSConnection
I don't know specifically about how RedHat package Python but it's possible you need to install SSL support in addition to the main language. I believe this is a separate compilation option:
http://www.webtop.com.au/blog/compiling-python-with-ssl-support-fedora-10-2009020237

OpenERP trunk server gives import Error psutil

I download trunk version of OpenERP from lauchpad. When i start server it's gives following error
Traceback (most recent call last):
File "./openerp-server", line 2, in
import openerp
File "/home/jack/trunk/trunk-server/openerp/init.py", line 72, in
import http
File "/home/jack/trunk/trunk-server/openerp/http.py", line 37, in
from openerp.service import security, model as service_model
File "/home/jack/trunk/trunk-server/openerp/service/init.py", line 28, in
import server
File "/home/jack/trunk/trunk-server/openerp/service/server.py", line 10, in
import psutil
ImportError: No module named psutil
Getting this error because psutil is not installed. you have to install psutil using this command.
sudo apt-get install python-psutil in terminal. after this restart server. This will solve your error.

Import error Twisted on windows

While trying to run a simple twisted code, I get the following error
Traceback (most recent call last):
File "C:\Python25\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 322, in RunScript
debugger.run(codeObject, __main__.__dict__, start_stepping=0)
File "C:\Python25\Lib\site-packages\Pythonwin\pywin\debugger\__init__.py", line 60, in run
_GetCurrentDebugger().run(cmd, globals,locals, start_stepping)
File "C:\Python25\Lib\site-packages\pythonwin\pywin\debugger\debugger.py", line 655, in run
exec cmd in globals, locals
File "C:\Users\Sony\Desktop\my.py", line 1, in <module>
from twisted.internet.protocol import Protocol, Factory
ImportError: No module named twisted.internet.protocol
I installed twisted using the .exe installer successfully.
Make sure you installed right version of twisted. For example, if you are using python 2.7, twisted installer should like: Twisted-13.0.0.win32-py2.7.msi
Installer will configure Environment PATH, if not u must configure then restart Windows.

Categories