I try to install dash on a mac OS, and I have the following error when running 'import dash' on a python script:
Traceback (most recent call last):
File "app.py", line 16, in <module>
import dash
File "/Users/manuel/Library/Python/3.9/lib/python/site-packages/dash/__init__.py", line 5, in <module>
from .dash import Dash, no_update # noqa: F401,E402
File "/Users/manuel/Library/Python/3.9/lib/python/site-packages/dash/dash.py", line 17, in <module>
from flask_compress import Compress
File "/Users/manuel/Library/Python/3.9/lib/python/site-packages/flask_compress/__init__.py", line 1, in <module>
from .flask_compress import Compress
File "/Users/manuel/Library/Python/3.9/lib/python/site-packages/flask_compress/flask_compress.py", line 14, in <module>
import brotli
File "/Users/manuel/Library/Python/3.9/lib/python/site-packages/brotli.py", line 8, in <module>
import _brotli
ModuleNotFoundError: No module named '_brotli'
I can't figure it out what is the problem. I use python 3.7. I saw on the internet a similar issue on windows, but not on mac. I would be really grateful if you could help me.
You seem to have a broken installation of the brotli module (missing its native code component _brotli).
Try uninstalling it with pip uninstall brotli, then reinstall it; pip install brotli.
Going forward, I would heavily recommend you learn and use virtualenvs instead of installing everything into your Python's site-packages.
After uninstalling and installing again brotli it worked! Moreover, working in virtual environments is really more appropriate. Thank you a lot, AKX.
I ran both
sudo pip install asprise_ocr_sdk_python_api
pip install asprise_ocr_sdk_python_api
Got message
"Requirement already satisfied: asprise_ocr_sdk_python_api in /Users/myid/miniconda3/envs/competition/lib/python3.5/site-packages"
But when I ran asprise_ocr to test:
Got the following error:
Traceback (most recent call last):
File "/Users/myuser/miniconda3/envs/competition/bin/asprise_ocr", line 7, in <module>
from asprise_ocr_api.ocr_app import run_ocr_app
File "/Users/myuser/miniconda3/envs/competition/lib/python3.5/site-packages/asprise_ocr_api/__init__.py", line 1, in <module>
from ocr import *
ImportError: No module named 'ocr'
The asprise_ocr_api module doesn't do submodule imports correctly in Python 3.
For example init.py contains from ocr import *. For a sub-module in Python 3 that should be from .ocr import *. Idem for from ocr_app import OcrApp, run_ocr_app. That should be from .ocr_app import OcrApp, run_ocr_app.
After making these changes in all files it imports correctly.
i've tried:
import ocr
same error:
ModuleNotFoundError: No module named 'ocr'
i am using python 3
I downloaded the and installed the twitter wrapper for python from:
https://python-twitter.googlecode.com/files/python-twitter-1.1.tar.gz
This is all i have in my code now:
import simplejson
import httplib2
import twitter
This is the error i get:
Traceback (most recent call last):
File "C:\Python27\Scripts\tweets.py", line 3, in <module>
import twitter
File "build\bdist.win-amd64\egg\twitter.py", line 38, in <module>
File "C:\Python27\lib\site-packages\requests_oauthlib-0.4.0-py2.7.egg\requests_oauthlib\__init__.py", line 1, in <module>
from .oauth1_auth import OAuth1
File "C:\Python27\lib\site-packages\requests_oauthlib-0.4.0-py2.7.egg\requests_oauthlib\oauth1_auth.py", line 3, in <module>
from oauthlib.common import extract_params
ImportError: No module named oauthlib.common
Which module can i install to stop this error?
https://github.com/idan/oauthlib
Try to install oauthlib to fix the error.
https://github.com/idan/oauthlib
Try to install oauthlib to fix the
error. answered Oct 11 at 12:32 by xiaowl
The above worked for me. I was installing python-twitter and its dependencies in a web2py application /modules subdirectory and was getting a similar error. I installed oauthlib from the above link and all is happy.
Thanks, Xiaowl.
I tried to get atpy on python 2.7. I downloaded ATpy0.9.6 from
https://pypi.python.org/pypi/ATpy/0.9.6
then tar it, and run:
cd ATpy0.9.6
sudo python setup.py install
things seemed to work well.
But when I tried to import atpy on python, I got always this error message:
ImportError: No module named astropy.io
More precisely,
>>> import atpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/atpy/__init__.py", line 1, in <module>
from .basetable import Table, TableSet, VectorException
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/atpy/basetable.py", line 15, in <module>
from . import registry
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/atpy/registry.py", line 164, in <module>
from . import fitstable
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/atpy/fitstable.py", line 8, in <module>
from astropy.io import fits
ImportError: No module named astropy.io
>>>
Could anyone help me to figure out the problem?
Perhaps the 'atpy' package depends on another package called 'astropy.io' that you are missing? Yes here it is https://astropy.readthedocs.org/en/v0.1/index.html
It happens that downloading the tar balls from pypi.python.org is the wrong way to install Python packages. The right way (though the Python docs explain poorly), is to run a command like
pip install atpy
This command will install your package and all its dependencies.
If the command pip is missing, you have to install it, which is ironically really complicated.
In my case the solution was to install astropy
pip install --no-deps astropy
I'm following this post to make one ipython rule all the virtualenvs.
From what I understand, the main idea of the post is that when in a virtualenv, ipython can not find its modules.
(a-virtualenv)me#pc:~$ ipython
Traceback (most recent call last):
File "/usr/bin/ipython", line 19, in <module>
from IPython.frontend.terminal.ipapp import launch_new_instance
ImportError: No module named IPython.frontend.terminal.ipapp
To work around this, I add this to my /usr/bin/ipython
import sys
if "/usr/lib/python2.7/dist-packages" not in sys.path:
sys.path.append("/usr/lib/python2.7/dist-packages")
This trick works for Balthazar. But in my case, I get this
Traceback (most recent call last):
File "/usr/bin/ipython", line 18, in <module>
from IPython.frontend.terminal.ipapp import launch_new_instance
File "/usr/lib/python2.7/dist-packages/IPython/__init__.py", line 46, in <module>
from .frontend.terminal.embed import embed
File "/usr/lib/python2.7/dist-packages/IPython/frontend/terminal/embed.py", line 37, in <module>
from IPython.frontend.terminal.ipapp import load_default_config
File "/usr/lib/python2.7/dist-packages/IPython/frontend/terminal/ipapp.py", line 38, in <module>
from IPython.core.completer import IPCompleter
File "/usr/lib/python2.7/dist-packages/IPython/core/completer.py", line 84, in <module>
from IPython.utils import generics
File "/usr/lib/python2.7/dist-packages/IPython/utils/generics.py", line 19, in <module>
from IPython.external.simplegeneric import generic
File "/usr/lib/python2.7/dist-packages/IPython/external/simplegeneric/__init__.py", line 4, in <module>
from _simplegeneric import *
ImportError: No module named _simplegeneric
I thought maybe I should add /usr/lib/python2.7/dist-packages/IPython/external to sys.path in /usr/bin/ipython as well. What I get is
Traceback (most recent call last):
File "/usr/bin/ipython", line 18, in <module>
from IPython.frontend.terminal.ipapp import launch_new_instance
File "/usr/lib/python2.7/dist-packages/IPython/__init__.py", line 43, in <module>
from .config.loader import Config
File "/usr/lib/python2.7/dist-packages/IPython/config/loader.py", line 27, in <module>
from IPython.utils.path import filefind, get_ipython_dir
File "/usr/lib/python2.7/dist-packages/IPython/utils/path.py", line 24, in <module>
from IPython.utils.process import system
File "/usr/lib/python2.7/dist-packages/IPython/utils/process.py", line 27, in <module>
from ._process_posix import _find_cmd, system, getoutput, arg_split
File "/usr/lib/python2.7/dist-packages/IPython/utils/_process_posix.py", line 27, in <module>
from IPython.utils import text
File "/usr/lib/python2.7/dist-packages/IPython/utils/text.py", line 27, in <module>
from IPython.external.path import path
ImportError: cannot import name path
This error occurred on line 43 of IPython/__init__py, but the previous one occurred on line 46.
How can I make ipython work with virtualenv?
How can adding /usr/lib/python2.7/dist-packages/IPython/external to sys.path resulting a new error?
What should I read to get a better understanding of python import path?
Thanks!
PS:
normal IPython sys.path
['',
'/usr/bin',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-linux2',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages/PIL',
'/usr/lib/python2.7/dist-packages/gst-0.10',
'/usr/lib/python2.7/dist-packages/gtk-2.0',
'/usr/lib/pymodules/python2.7',
'/usr/lib/python2.7/dist-packages/ubuntu-sso-client',
'/usr/lib/python2.7/dist-packages/ubuntuone-client',
'/usr/lib/python2.7/dist-packages/ubuntuone-control-panel',
'/usr/lib/python2.7/dist-packages/ubuntuone-couch',
'/usr/lib/python2.7/dist-packages/ubuntuone-installer',
'/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol',
'/usr/lib/python2.7/dist-packages/IPython/extensions']
IPython seems to work now!
Because ipython can not find simplegeneric. I tried to locate simplegeneric and found simplegeneric is in '/usr/lib/pymodules/python2.7'. After '/usr/lib/pymodules/python2.7' being added, ipython works fine.
Jeff Tratner's comment really helps!
If you install ipython3 using apt-get, you would not face any problems like that.
Instead of ipython, you should type ipython3 on the terminal.
For Python 2 use ipython2.
Making changes to the path did not help in any way. However running ipython as a super user worked (although I'm not proud of it!)
sudo ipython
pip install ipython instead of apt-get install ipython. The former installs into the virtualenv, the latter installs into your system python packages.
I had the same problem, in my case the cause of it was that the directory: /usr/lib/python2.7/dist-packages was not added to the path when the virtual environment was created (I would like to know why)
In my case the following in the terminal solved the problem:
workon 'your_environment_here'
add2virtualenv /usr/lib/python2.7/dist-packages
Note: This assumes you are using virtualenvwrapper
In my case, it was a package higher up in my customized Python path named "path" that was causing the ImportError from:
import IPython.external.path as path
See https://github.com/ipython/ipython/issues/3994
I experienced some weirdness in a new ubuntu host, and realized I was getting different behaviors for mkvirtualenv on mac versus the ubuntu. I got past this difference with
'mkvirtualenv --system-site-packages mynewenv'
For me, the solution was to upgrade IPython from 0.13.2 to the currently newest 4.0.0.
Similar traceback I experienced with python 3.5.4 and pip 10.0.1 after installing ipython successfully.
line 32, in <module>
from .debugger import TerminalPdb, Pdb
File "/usr/lib/python3.5/site-packages/IPython/terminal/debugger.py", line 6, in <module>
from IPython.core.completer import IPCompleter
File "/usr/lib/python3.5/site-packages/IPython/core/completer.py", line 137, in <module>
from IPython.utils import generics
File "/usr/lib/python3.5/site-packages/IPython/utils/generics.py", line 8, in <module>
from simplegeneric import generic
ImportError: No module named 'simplegeneric'
updating or installing the simplegeneric i.e sudo pip install simplegeneric --upgrade I get
Requirement already up-to-date: simplegeneric in /usr/lib/python3.5/site-packages (0.8.1)
After some initial trial I searched on google/stackoverflow to see if anyone else faced similar problem and found this. And its #zjk answer that helps me to find solution.
Solutions:
Found only egg folder in the python3.5 installed package dir. So I removed them and fresh install the simplegeneric.
sudo rm -rf /usr/lib/python3.5/site-packages/simplegeneric-0.8.1-py3.5.egg-info/
sudo pip install simplegeneric
after that ipython worked just like charm.
N.B: I install the package at the system level that's why sudo required.