I have successfully installed the bitarray package, because I can find it after the command: pip list.
But when I try to import it I get :
>>> from bitarray import bitarray
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
from bitarray import bitarray
ModuleNotFoundError: No module named 'bitarray'
What can I try to solve it ?
I'm using Ubuntu 18.04.5 .
You can install package as python3 -m pip install bitarray. May be when you did pip install bitarray, it install your package for python2.
Ubuntu comes with two python versions. If you just ran pip install x it installed it into python 2.7. You're probably using python3, so you wanna install with pip3 install x
Just to make sure you are running correct pip, try running "pip -V" or "pip --version", it gives you which version of python it refers to. In terminal it looks something like this pip version check
Its also possible that you might have pip for say python 2.7, pip3 for python 3.6, and pip3.7 for python 3.7, if you have multiple versions of python installed.
For simplicity you can set the most frequently used pip version as pip by setting an alias in ~/.bashrc. This is done by adding the following line in bashrc:
alias pip=pip3.6.
After this you can try and install the packages and import it swiftly.
I am running Anaconda on macOS Sierra utilising Python 2.7. I want to be able to run spykeviewer https://anaconda.org/pypi/spykeviewer
however I keep receiving this error:
*Traceback (most recent call last):
File "/Users/becky/anaconda/envs/spykeviewer-en/bin/spykeviewer", line 11, in <module>
sys.exit(main())
File "/Users/becky/anaconda/envs/spykeviewer-en/lib/python2.7/site-packages/spykeviewer/start.py", line 42, in main
from ui.main_window_neo import MainWindowNeo
File "/Users/becky/anaconda/envs/spykeviewer-en/lib/python2.7/site-packages/spykeviewer/ui/main_window_neo.py", line 16, in <module>
from spyderlib.widgets.variableexplorer.collectionseditor import \
ImportError: No module named spyderlib.widgets.variableexplorer.collectionseditor*
I have all of the dependent packages downloaded and I have reinstalled spyder as the error seems to be pointing to this module but I still get the same import error.
Here is how I installed the different packages:
conda install pyqt=4
conda install scipy
conda install gdata
conda install matplotlib
conda install pytables
conda install spyder
tables already installed in the environment
from terminal -> into guidata folder -> python setup.py install
from terminal -> into quiqwt -> python setup.py install
both are then in root —> open terminal in spykeviewer-en —> pip install guidata
condo install cython
pip install guiqwt
pip install neo
pip install spykeutils
pip install spykeviewerenter
I have started to install SciPy using:
pip install --user numpy scipy matplotlib ipython jupyter pandas simply nose
It installed but when I want to go into ipython I get this error:
ImportError: No module named shutil_get_terminal_size
I tried uninstalling python then reinstalling it as well as uninstalling and reinstalling SciPy. I've also upgraded pip setup tools as well as python. It says that shutil_get_terminal_size has been installed:
Traceback (most recent call last):
File "/usr/local/bin/ipython", line 7, in <module>
from IPython import start_ipython
File "/usr/local/lib/python2.7/site-packages/IPython/__init__.py", line 48, in <module>
from .core.application import Application
File "/usr/local/lib/python2.7/site-packages/IPython/core/application.py", line 25, in <module>
from IPython.core import release, crashhandler
File "/usr/local/lib/python2.7/site-packages/IPython/core/crashhandler.py", line 28, in <module>
from IPython.core import ultratb
File "/usr/local/lib/python2.7/site-packages/IPython/core/ultratb.py", line 128, in <module>
from IPython.utils.terminal import get_terminal_size
File "/usr/local/lib/python2.7/site-packages/IPython/utils/terminal.py", line 22, in <module>
from backports.shutil_get_terminal_size import get_terminal_size as _get_terminal_size
ImportError: No module named shutil_get_terminal_size
I just need to be able to get SciPy and ipython working.
You need to update your version of pip and then install ipython again.
sudo pip install --upgrade setuptools pip
pip uninstall --user ipython
pip install --user ipython
I have also faced the same issue.This is the issue of conda environment. That's why it is giving the error in ipython notebook.Try out this one.
conda update conda
conda update ipython
After trying this,if you are facing same issue.then try to install ipython inside your conda environment.Activate your conda environment first.then do as follows.
pip install --upgrade setuptools pip
ex: (dato-env) pydev#Optimus:~$ pip install --upgrade setuptools pip
then install ipython inside conda environment
pip install -U ipython
ex : (dato-env) pydev#Optimus:~$ pip install -U ipython
then open Jupyter notebook from the terminal and it will open jupyter on your browser.
(dato-env) pydev#Optimus:~$ jupyter notebook
Hope it helps.
When I installed OpenCV using Homebrew (brew), I got this problem whenever I run this command to test python -c "import cv2":
RuntimeError: module compiled against API version 9 but this version of numpy is 6
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: numpy.core.multiarray failed to import
I tried to upgrade NumPy, but this is confusing:
>>> import numpy
>>> print numpy.__version__
1.6.1
When I run brew to upgrade NumPy, I got this problem:
brew install -u numpy
Warning: numpy-1.9.1 already installed
When I uninstalled it:
sudo pip install numpy
Requirement already satisfied (use --upgrade to upgrade): numpy in ./anaconda/lib/python2.7/site-packages
I have followed this question and deleted Anaconda from my mac.
pip install numpy
Requirement already satisfied (use --upgrade to upgrade): numpy in /Library/Python/2.7/site-packages
But nothing have changed. How can I link the NumPy version to OpenCV?
When you already have an older version of NumPy, use this:
pip install numpy --upgrade
If it still doesn't work, try:
pip install numpy --upgrade --ignore-installed
Because we have two NumPy installations in the system. One is installed by Homebrew and the second is installed by pip. So in order to solve the problem, we need to delete one and use the default NumPy install by OpenCV.
Check the path,
import numpy
print numpy.__path__
and manually delete it using rm.
The error you mentioned happens when you have two versions of NumPy on your system. As you mentioned, the version of NumPy you imported is still not upgraded since you tried to upgrade it through pip (it will upgrade the version existing in '/Library/Python/2.7/site-packages' ).
However Python still loads the packages from '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy' where the pre-installed packages live.
In order to upgrade that version you have to use easy_install. The other way around this problem is using virtualenv and setting up a new environment with all the requirements you need.
Update numpy
For python 2
pip install numpy --upgrade
You would also needed to upgrade your tables as well for updated version of numpy. so,
pip install tables --upgrade
For python 3
pip3 install numpy --upgrade
Similarly, the tables for python3 :-
pip3 install tables --upgrade
note:
You need to check which python version are you using. pip for python 2.7+ or pip3 for python 3+
FYI, when you using or importing TensorFlow, a similar error may occur, like (caused by NumPy):
RuntimeError: module compiled against API version 0xa but this version of numpy is 0x9
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/__init__.py", line 23, in <module>
from tensorflow.python import *
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py", line 60, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
_pywrap_tensorflow = swig_import_helper()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
ImportError: numpy.core.multiarray failed to import
Error importing tensorflow. Unless you are using bazel,
you should not try to import tensorflow from its source directory;
please exit the tensorflow source tree, and relaunch your python interpreter
from there.
I followed Elmira's and Drew's solution, sudo easy_install numpy, and it worked!
sudo easy_install numpy
Searching for numpy
Best match: numpy 1.11.3
Removing numpy 1.8.2 from easy-install.pth file
Adding numpy 1.11.3 to easy-install.pth file
Using /usr/local/lib/python2.7/dist-packages
Processing dependencies for numpy
Finished processing dependencies for numpy
After that I could use TensorFlow without error.
I tried doing sudo pip uninstall numpy instead, because the rm didn't work at first.
Hopefully that helps.
Uninstalling then to install it again.
Because you have multiple versions of NumPy installed.
Try pip uninstall numpy and pip list | grep numpy several times, until you see no output from pip list | grep numpy.
Then pip install numpy will get you the newest version of NumPy.
This works for me:
pip install numpy --upgrade
If you don't encounter any permission errors with
pip install -U numpy
try:
pip install --user -U numpy
All the same.
sudo easy_install numpy
My Traceback
Searching for numpy
Best match: numpy 1.13.0
Adding numpy 1.13.0 to easy-install.pth file
Using /Library/Python/2.7/site-packages
Processing dependencies for numpy
After installing pytorch, I got a similar error when I used:
import torch
Removing NumPy didn't help (I actually renamed NumPy, so I reverted back after it didn't work). The following commands worked for me:
sudo pip install numpy --upgrade
sudo easy_install numpy
If you are using multiple versions of Python (for example 3.8 and 3.9), then specify explicitly for which one you want to install and update numpy:
python3.8 -m pip install numpy --upgrade
# or
python3.9 -m pip install numpy --upgrade
Then run your program with the appropriate version of Python.
If you are stuck with a machine where you don't have root access, then it is better to deal with a custom Python installation.
The Anaconda installation worked like a charm:
Installing packages (SciPy.org)
Anaconda Python/R Distribution - download
After installation,
[bash]$ /xxx/devTools/python/anaconda/bin/pip list --format=columns |
grep numpy
numpy 1.13.3 numpydoc
0.7.0
pip install numpy --upgrade
You can try to use the ablove command and use as adminstrator if open CMD.
Hello I've installed a local version of pip using
python get-pip.py --user
After that I can't find the path of pip, so I run:
python -m pip install --user Cython
Finally I can't import Cython
import Cython
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'Cython'
Use virtualenv, it is used to create isolated python environments (check this quick guide http://docs.python-guide.org/en/latest/dev/virtualenvs/ )
python -m pip install --user Cython
should probabably be
pip install --user cython