ImportError: No module named deploy - python-2.7

root#ubuntu:/home/ubuntu#
root#ubuntu:/home/ubuntu# python
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import paste
>>> import paste.deploy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named deploy
>>> from paste import deploy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name deploy
>>> from paste.deploy import loadwsgi
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named deploy
why i can import the paste,but i cannot import the paste.deploy.
i run the python by root,please explain it. i am a new python

paste and paste.deploy are 2 separate modules.
You have to install both of them.
To install paste.deploy:
pip install pastedeploy
If it installed correctly, you should be able to run the following in the python interpreter to confirm it's available for use:
>>> import paste
>>> import paste.deploy
>>> paste.deploy.__path__
['/Users/joeyoung/.virtualenvs/reversemapping/lib/python2.7/site-packages/paste/deploy']
Packages support one more special attribute, ____path____. This is
initialized to be a list containing the name of the directory holding
the package’s ____init____.py before the code in that file is executed.
https://docs.python.org/2.7/tutorial/modules.html#packages-in-multiple-directories

$ pip uninstall paste
$ pip install paste

first,uninstall paste or paste deploy
second,install paste deploy by follows:
$ hg clone http://bitbucket.org/ianb/pastedeploy
$ cd pastedeploy
$ sudo python setup.py develop
it will work well.

Related

Cannot import mysql.connector in Python 2.7.12

I cannot import mysql.connector in python 2.7.12. I cannot upgrade my python version, because some other servers are running on it.
>>> import mysql.connector
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\mysql\connector\__init__.py", line 53, in <module>
from .connection import MySQLConnection
File "C:\Python27\lib\site-packages\mysql\connector\connection.py", line 518
f"This connection is using {tls_version} which is now "
^
SyntaxError: invalid syntax
This is the error I am getting even though I installed mysql-connector-python. Can someone please help me with this?
As I stated in my comment, you're most likely using a more recent mysql-connector-python.
From the list of version in PyPI, this might be the last one that supports 2.7:
https://pypi.org/project/mysql-connector-python/8.0.23/
This docs discusses that 2.7 was removed in 8.0.24:

Getting "No module named queue" when installing tensorflow

I am using Anaconda and trying to install tensorflow with pip, but I receive the following error and I am not sure what to do next?
Traceback (most recent call last):
File "/home/xieyangyang/anaconda3/envs/tensorflow1/bin/pip", line 7, in <module>
from pip._internal import main
File "/home/xieyangyang/anaconda3/envs/tensorflow1/lib/python2.7/site-packages/pip/_internal/__init__.py", line 20, in <module>
from pip._vendor.urllib3.exceptions import DependencyWarning
File "/home/xieyangyang/anaconda3/envs/tensorflow1/lib/python2.7/site-packages/pip/_vendor/urllib3/__init__.py", line 8, in <module>
from .connectionpool import (
File "/home/xieyangyang/anaconda3/envs/tensorflow1/lib/python2.7/site-packages/pip/_vendor/urllib3/connectionpool.py", line 44, in <module>
from .util.queue import LifoQueue
ImportError: No module named queue
Maybe just reinstall pip without pip?
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
See https://pip.pypa.io/en/stable/installing/ for more info.

Install Django using setup file in Python 2.7

I am trying to install Diango via setup up file then it shows the following error:
hari#hari-HP-Pavilion-g6-Notebook-PC:~/Downloads/django-master$ sudo python setup.py install
Traceback (most recent call last):
File "setup.py", line 32, in <module>
version = __import__('django').get_version()
File "/home/hari/Downloads/django-master/django/__init__.py", line 1, in <module>
from django.utils.version import get_version
File "/home/hari/Downloads/django-master/django/utils/version.py", line 60, in <module>
#functools.lru_cache()
AttributeError: 'module' object has no attribute 'lru_cache'
How to fix this error?
Maybe the zip file from github is only for windows, but i see that you are using linux so:
1) Use PIP (Use sudo as you are not inside virtualenv)
sudo pip install Django==1.10.6
2) Use GIT
git clone https://github.com/django/django.git
Hope this help
I have the same problem when install Diango
then I use this in cmd
>>>> import functools
>>> dir(functools)
['WRAPPER_ASSIGNMENTS', 'WRAPPER_UPDATES', '__builtins__', '__doc__', '__file__'
, '__name__', '__package__', 'cmp_to_key', 'partial', 'reduce', 'total_ordering'
, 'update_wrapper', 'wraps']
you can see there is not lru_cache..so, I think this is the reason..
then I installed Python3.6.1
>>> import functools
>>> dir(functools)
['MappingProxyType', 'RLock', 'WRAPPER_ASSIGNMENTS', 'WRAPPER_UPDATES', 'WeakKey
Dictionary', '_CacheInfo', '_HashedSeq', '__all__', '__builtins__', '__cached__'
, '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '_
c3_merge', '_c3_mro', '_compose_mro', '_convert', '_find_impl', '_ge_from_gt', '
_ge_from_le', '_ge_from_lt', '_gt_from_ge', '_gt_from_le', '_gt_from_lt', '_le_f
rom_ge', '_le_from_gt', '_le_from_lt', '_lru_cache_wrapper', '_lt_from_ge', '_lt
_from_gt', '_lt_from_le', '_make_key', 'cmp_to_key', 'get_cache_token', 'lru_cache', 'namedtuple', 'partial', 'partialmethod', 'recursive_repr', 'reduce', 'sing
ledispatch', 'total_ordering', 'update_wrapper', 'wraps']
you can see lru_cache there, I wish it's helpful for you (sorry for my English, I'm not good at this..)

Python & requests | ImportError: No module named util

I just installed the package requests on a new computer. I'm getting this error when I try to import that module. Any ideas what's causing the issue w/ the util module?
Python 2.7.6 (v2.7.6:3a1db0d2747e, Nov 10 2013, 00:42:54)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests-2.3.0-py2.7.egg/requests/__init__.py", line 58, in <module>
from . import utils
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests-2.3.0-py2.7.egg/requests/utils.py", line 25, in <module>
from .compat import parse_http_list as _parse_list_header
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests-2.3.0-py2.7.egg/requests/compat.py", line 7, in <module>
from .packages import chardet
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests-2.3.0-py2.7.egg/requests/packages/__init__.py", line 3, in <module>
from . import urllib3
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests-2.3.0-py2.7.egg/requests/packages/urllib3/__init__.py", line 16, in <module>
from .connectionpool import (
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests-2.3.0-py2.7.egg/requests/packages/urllib3/connectionpool.py", line 36, in <module>
from .connection import (
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests-2.3.0-py2.7.egg/requests/packages/urllib3/connection.py", line 43, in <module>
from .util import (
ImportError: No module named util
on pypi.python.org I see, that latest version of requests is 2.2.1
Your listing shows, you have installed version 2.3.0, so it is likely, you are using development version which is not yet really completed.
Uninstal it:
$ pip uninstall requests
And install production quality one:
$ pip install requests
In case, it would still mess up with version 2.3.0, install explicitly the 2.2.1
$ pip install requests==2.2.1
As seen here Bug 1459100
I have do execute the following commands:
# mv /usr/lib/python2.7/site-packages/requests /usr/lib/python2.7/site-packages/requests_old
then
dnf install python-requests --best --allowerasing
So, finally I can start virt-manager again.
My system specs:
Fedora 25
$ /usr/lib/
python2.7/ python3.5/

Unable to import installed packages in python after updating OSX and python

I recently updated my system (OXS 10.9.1 -> 10.9.2), and my python using brew (2.7.3 -> 2.7.6).
Now I am getting very strange behaviour. One example is trying to run a test app which creates flask sockets:
jono#air:~/Workspace/sandbox $ python app.py
Traceback (most recent call last):
File "app.py", line 9, in <module>
import flask, flask_sockets, time, threading, simplejson
File "/usr/local/lib/python2.7/site-packages/flask/__init__.py", line 21, in <module>
from .app import Flask, Request, Response
File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 26, in <module>
from . import json
File "/usr/local/lib/python2.7/site-packages/flask/json.py", line 25, in <module>
from itsdangerous import json as _json
ImportError: No module named itsdangerous
First thought is to update itsdangerous:
jono#air:~/Workspace/sandbox $ pip install itsdangerous --upgrade
Requirement already up-to-date: itsdangerous in /usr/local/lib/python2.7/site-packages
Cleaning up...
Checking that it installed correctly:
jono#air:~/Workspace/sandbox $ locate itsdangerous
/usr/local/lib/python2.7/site-packages/itsdangerous-0.23-py2.7.egg-info
/usr/local/lib/python2.7/site-packages/itsdangerous-0.23-py2.7.egg-info/PKG-INFO
/usr/local/lib/python2.7/site-packages/itsdangerous-0.23-py2.7.egg-info/SOURCES.txt
/usr/local/lib/python2.7/site-packages/itsdangerous-0.23-py2.7.egg-info/dependency_links.txt
/usr/local/lib/python2.7/site-packages/itsdangerous-0.23-py2.7.egg-info/installed-files.txt
/usr/local/lib/python2.7/site-packages/itsdangerous-0.23-py2.7.egg-info/not-zip-safe
/usr/local/lib/python2.7/site-packages/itsdangerous-0.23-py2.7.egg-info/top_level.txt
/usr/local/lib/python2.7/site-packages/itsdangerous.py
/usr/local/lib/python2.7/site-packages/itsdangerous.pyc
Checking my PYTHONPATH:
jono#air:~/Workspace/sandbox $ echo $PYTHONPATH
/usr/local/lib/python2.7/site-packages/
Checking that python is looking in the correct PYTHONPATH:
jono#air:~/Workspace/sandbox $ python
Python 2.7.6 (default, Mar 6 2014, 10:46:26)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import itsdangerous
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named itsdangerous
>>> import os
>>> os.getenv("PYTHONPATH")
'/usr/local/lib/python2.7/site-packages/'
>>>
I'm having similar issues with other basic packages like virtualenv too:
jono#air:~/Workspace/sandbox $ virtualenv venv
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 5, in <module>
from pkg_resources import load_entry_point
File "build/bdist.macosx-10.9-x86_64/egg/pkg_resources.py", line 2720, in <module>
File "build/bdist.macosx-10.9-x86_64/egg/pkg_resources.py", line 588, in resolve
The `plugin_env` should be an ``Environment`` instance that contains
pkg_resources.DistributionNotFound: virtualenv==1.9.1
Is it installed?
jono#air:~/Workspace/sandbox $ pip install virtualenv --upgrade
Requirement already up-to-date: virtualenv in /usr/local/lib/python2.7/site-packages
Cleaning up...
But strangely this time python can see it:
jono#air:~/Workspace/sandbox $ python
Python 2.7.6 (default, Mar 6 2014, 10:46:26)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import virtualenv
>>> dir(virtualenv)
['ACTIVATE_BAT', 'ACTIVATE_CSH', 'ACTIVATE_FISH', 'ACTIVATE_PS', 'ACTIVATE_SH', 'ACTIVATE_THIS', 'BIG_ENDIAN', 'ConfigOptionParser', 'ConfigParser', 'DEACTIVATE_BAT', 'DISTUTILS_CFG', 'DISTUTILS_INIT', 'FAT_MAGIC', 'LC_LOAD_DYLIB', 'LITTLE_ENDIAN', 'Logger', 'MH_CIGAM', 'MH_CIGAM_64', 'MH_MAGIC', 'MH_MAGIC_64', 'OK_ABS_SCRIPTS', 'REQUIRED_FILES', 'REQUIRED_MODULES', 'SITE_PY', 'UpdatingDefaultsHelpFormatter', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '__version__', '_find_file', 'abiflags', 'base64', 'call_subprocess', 'change_prefix', 'codecs', 'convert', 'copy_required_modules', 'copyfile', 'copyfileordir', 'create_bootstrap_script', 'create_environment', 'default_config_file', 'default_storage_dir', 'distutils', 'errno', 'expected_exe', 'file_search_dirs', 'fileview', 'filter_install_output', 'find_wheels', 'fix_lib64', 'fix_local_scheme', 'fixup_egg_link', 'fixup_pth_and_egg_link', 'fixup_pth_file', 'fixup_scripts', 'get_installed_pythons', 'glob', 'install_activate', 'install_distutils', 'install_python', 'install_wheel', 'is_cygwin', 'is_darwin', 'is_executable', 'is_executable_file', 'is_jython', 'is_pypy', 'is_win', 'join', 'logger', 'logging', 'mach_o_change', 'main', 'majver', 'make_environment_relocatable', 'make_exe', 'make_relative_path', 'maxint', 'minver', 'mkdir', 'optparse', 'os', 'path_locations', 'py_version', 're', 'read_data', 'relative_script', 'resolve_interpreter', 'rmtree', 'shutil', 'strtobool', 'struct', 'subprocess', 'subst_path', 'sys', 'tarfile', 'tempfile', 'user_dir', 'virtualenv_version', 'writefile', 'zlib']
>>> virtualenv.is_darwin
True
>>> virtualenv.__file__
'/usr/local/lib/python2.7/site-packages/virtualenv.pyc'
>>>
Somehow, many of my packages in /usr/local/lib/python2.7/site-packages/ had root ownership. This was causing a host of issues :/
sudo pip uninstall XXX
followed by
pip install XXX
Resolved most of the issues.
Let the lesson be learnt that one should never 'sudo pip install' anything.