Having just upgraded to pip-18.0
all uses of pip produce this error:
...\site-packages\pip\_internal\__init__.py", line 5, in <module>
import logging
ModuleNotFoundError: No module named 'logging'
logging.py exists in \site-packages\pip\_internal\utils\
(and also contains an 'import logging' statement!)
I suppose I could move it up a directory level or update _init to 'import utils.logging'
In fact lots of my programs' packages eg numpy are now failing with no logging module. I have now identified the problem:
import logging
Traceback (most recent call last):
File "", line 1, in
import logging
ModuleNotFoundError: No module named 'logging'
import lib2to3.logging
lib2to3 is a subdir of Lib, containing the logging module,
but is no longer found in the module search.
In my case, running OpenWrt/LEDE 17.01.4 on the client, I had installed most of Python3 via:
opkg install python3-light
when I received the ImportError: No module named logging. I needed to separately install the logging package:
opkg install python3-logging
The above is enough to run the Ansible ping module. To run the setup module you also need:
opkg install python3-multiprocessing python3-distutils
I fixed it by moving logging up from Lib/lib2to3/ to Lib/
where import canm now find it.
I would add to #bitinerant 's answer that also the following package needs to be installed:
opkg install python-openssl python-codecs
for the ping and setup modules to work on python2 based systems
Related
I am writing my own package for a test with setup.py. I tried to install it on my own computer with python3 setup.py install, and there was no error. I checked with pip3 list and found it there,
steplib 0.1.0
However, when I tried importing it in a python interpreter, I could not,
>>> import steplib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'steplib'
Using help('modules') confirmed this as it was not shown in the list.
Am I doing anything wrong? Do I have to register it first before using it?
edit
My site packages contains steplib-0.1.0-py3.7.egg-info. It does not have any sub-packages (it is a test package):
steplib
__init__.py
steplib.py
setup.py
Ideally module should go into your site packages. Do you see it there?
If its there then check your package path. You package may be steplib, but have you checked if you are importing right package and module there. For example within your steplib folder you might have additional package and module within it. Say package is X and module is Y. Then you can import it as below.
from X import Y
Make sure you have init.py in your package to qualify that as a package.
Did you install the package in the python directory under Lib?
I need help with the pyodbc Python module. I installed it via Canopy package management, but when I try to import it, I get an error (no module named pyodbc). Why?
Here's the output from my Python interpreter:
import pyodbc
Traceback (most recent call last):
File "", line 1, in
import pyodbc
ImportError: No module named 'pyodbc
For the record: the attempted import was in a different Python installation. It is never good, and usually impossible, to use a package which was installed into one Python installation, in another Python installation.
I downloaded python-somelib-master.zip from GitHub hoping to use the API it provides. I ran
python setup.py install
And it apparently completed successfully:
Writing D:\SOFT\Python3\Lib\site-packages\python-somelib-1.0-py3.5.egg-info
which then introduced D:\SOFT\Python3\Lib\site-packages\somelib.
However, when I try to import something from there in my script:
from somelib import SubModule
I get
File "D:\SOFT\Python3\lib\site-packages\somelib\__init__.py", line 1, in <module>
from base import SubModule
ImportError: No module named 'base'
I confirmed that base.py is present in D:\SOFT\Python3\Lib\site-packages\somelib.
Did I not properly install the module?
You must install modules dependencies in your machine too. If you are using Ubuntu, you can easily do it with "apt-get". Hope it helps! xD
I am trying to get Django running on a shared hosting account for which I have ssh access, but I have been having issues getting it working. When I first tried running django-admin.py, I received an error about the module 'functools' being missing. I had the hosting company install the functools package, but now I get the following traceback when I try to run django-admin.py.
Traceback (most recent call last):
File "manage.py", line 2, in <module>
from django.core.management import execute_manager
File "/usr/local/lib/python2.6/site-packages/Django-1.3-py2.6.egg/django/core/management/__init__.py", line 3, in <module>
from optparse import OptionParser, NO_DEFAULT
File "/usr/local/lib/python2.6/optparse.py", line 90, in <module>
from gettext import gettext
File "/usr/local/lib/python2.6/gettext.py", line 49, in <module>
import locale, copy, os, re, struct, sys
File "/usr/local/lib/python2.6/locale.py", line 98, in <module>
#functools.wraps(_localeconv)
AttributeError: 'module' object has no attribute 'wraps'
I opened a support ticket and was told by the company that they reinstalled Python 2.6, but that didn't change anything. I also tried with 2.4, which is also installed on the machine, but that resulted in the earlier ImportError: No module named functools error.
Does anybody have any ideas?
A likely cause is something shadowing the stdlib functools module. Do you have a functools.py alongside the main script (manage.py)? See what import functools; print functools.__file__ prints, inside manage.py (before any of the other imports.) If it doesn't print /usr/local/lib/python2.6/functools.py, there's probably a file shadowing the standard library module. If it does print that, something is wrong with that file, reinstalls notwithstanding.
this solution worked for me .
mv /usr/lib/python2.7/site-packages/pip* ./
yum reinstall python-pip
sudo pip install django
or try an another solution .
its too risky and this might not be a safest solution.but it worked fine for me .
uninstall pip.
pip uninstall pip
if you installed by get-pip.py .
python -m pip uninstall pip setuptools
navigate to the path.
/usr/lib/python2.7/site-packages/
and find out two pip directories pip and pip-6.0.8.dist-info.
remove both pip and pip-6.0.8.dist-info.
then try again.
yum install python-pip
or
python get-pip.py
I'm using cairo plot to draw charts with python. I followed the instruction as stated on the website to install Cairplot, http://linil.wordpress.com/2008/09/16/cairoplot-11/ :
sudo apt-get install bzr
bzr branch lp:cairoplot/1.1
The installation completes successfully.
I then try to import the modules in python:
>>> import CairoPlot Traceback (most recent call last): File "<stdin>",
line 1, in <module> ImportError: No
module named CairoPlot
>>> import cairo
>>>
Importing cairo is fine, but I can't figure out why I am not able to import CairoPlot.
bzr branch lp:cairoplot/1.1 creates a directory called 1.1 in your current working directory. Inside you'll find CairoPlot.py. Move CairoPlot.py into a directory which is listed in your PYTHONPATH, or edit your PYTHONPATH to include (the unfortunately named) 1.1.
Is the directory where CairoPlot is installed in your $PYTHONPATH? Do you need to run any setup scripts, like setuptools?
The repository appears to include a setup.py file, so you likely need to run setuptools to fully install the module.