scoured many examples but couldn't find anything steps that resolved my issue. Python can't seem to find any package I install via PIP. For example:
tims-MacBook-Pro:~ timlindsey$ pip install numpy
Requirement already satisfied (use --upgrade to upgrade): numpy in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
however when I then go into python and try to import numpy
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named numpy
It appears to happen no matter what package I try to bring in via pip. I'll spare the text dump but numpy is indeed there in
pip list
it seems to be looking at the same python install:
tims-MacBook-Pro:~ timlindsey$ which python
/usr/local/bin/python
tims-MacBook-Pro:~ timlindsey$ which pip
/usr/local/bin/pip
here is my .bash_profile:
export ANDROID_HOME=/usr/local/opt/android-sdk
export PATH="/usr/local/sbin:$PATH"
export PATH="/usr/local/bin:$PATH"
export PATH="Users/timlindsey/anaconda/bin:$PATH"
source ~/.nvm/nvm.sh
I don't know where to go from here, any ideas?
Related
I am having issues with the numpy library. I am trying to code a webcam using the opencv library, but I am getting this issue:
OpenCV bindings requires "numpy" package.
Install it via command:
pip install numpy
Traceback (most recent call last):
File "/home/pi/Documents/security-camera/take_picture.py", line 1, in <module>
import cv2
File "/home/pi/.local/lib/python3.9/site-packages/cv2/__init__.py", line 12, in <module>
import numpy.core.multiarray
ModuleNotFoundError: No module named 'numpy.core.multiarray'
When I try to install numpy using pip, I get this error:
pi#raspberrypi:~/Documents/security-camera $ python3 -m pip install numpy
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: numpy in /usr/lib/python3/dist-packages (1.19.5)
It says I already have the numpy library, even though when I run it says to install it. Does anyone know how to fix it?
I figured out how to solve this issue: I was getting an issue with numpy earlier and was trying to reinstall it, so I deleted the numpy folder in /usr/lib/python3/dist-packages, then I tried to install it again but it did not work. Then I got this issue. There are actually two numpy folders in /usr/lib/python3/dist-packages, so when I deleted the one with the python files in it, and imported numpy in the python program, it says numpy did not exist, but when I tried to reinstall numpy with pip, it said it already existed because it looked at the other folder. So what I had to do was delete the other folder in /usr/lib/python3/dist-packages, and then reinstalling numpy worked.
i was using
pip install numpy
to install NumPy on my Mac. Then the terminal says that
Requirement already satisfied: numpy in
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
I guess it means Numpy is already installed?
but when i wrote
from numpy import array
a=array([1,3],int)
the python shell says
Traceback (most recent call last):
File "/Users/bamford/Documents/python/untitled-3.py", line 1, in <module>
from numpy import array
builtins.ModuleNotFoundError: No module named 'numpy'
what is going on?
Per the comments, notice that your sys.path includes directories whose names imply they are associated with Python3.6:
[... '/Library/Frameworks/Python.framework/Versions/3.6/lib/python36.zip', ...]
Yet NumPy has been installed in your Python2.7 distribution:
Requirement already satisfied: numpy in
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
(my emphasis) So your Wing101 IDE is using Python3, and not finding NumPy because NumPy has not (yet) been installed in your Python3 distribution.
One solution would be to install NumPy for your Python3 distribution. (Another, might be to configure Wing101 to run Python2.7.) Often, the pip executable associated with Python3 is named pip3 (to distinguish it from a Python2 version called pip.) So you might try
pip3 install numpy
to install NumPy.
Moral of the story: Every pip is associated with a particular Python distribution. pip is a Python script. When run, it calls the Python executable associated with that distribution.
To install modules for a particular Python using pip, you need to call the pip script which is associated with the desired Python executable.
The message pip shows in your system
Requirement already satisfied: numpy in
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
Here as you can note, numpy module is installed in python 2.7's directory.
You should install it in python 3.*'s directory. You can try that by
pip3 install numpy
pip3 installs python libraries in python 3.*directory
add sudo at the beginning of command to install it system wide.
homebrew has again broken python for about third time. Im now having issues getting dependencies to work again. At this point I am unable to install yaml.
Collecting yaml
Could not find a version that satisfies the requirement yaml (from versions: )
No matching distribution found for yaml
Some other suggestions have said to try pyaml, which again simply tries to import yaml and fails
Traceback (most recent call last):
File "script.py", line 13, in <module>
import pyaml
File "/~/virtualenv/project/lib/python2.7/site-packages/pyaml/__init__.py", line 6, in <module>
import os, sys, io, yaml
ImportError: No module named yaml
Anyone have an idea how to get this sorted out?
There are two packages with somewhat unfortunate naming in the Python Package Index.
pip install pyyaml lets you import yaml. This package enables Python to parse YAML files.
pip install pyaml lets you import pyaml. This package allows pretty-printing of YAML files from Python, among other things. It requires pyyaml to be installed.
So the way forward for you is:
Install pyyaml, preferably using pip
Install pyaml
Profit
Step 0 would be to run everything from a virtual environment to prevent homebrew from messing with your Python ever again. This option also lets you run multiple versions of Python, not just the one required by homebrew.
The solution for me turned out to be homebrew changing python to python2, which I believe precludes using the brew version instead of the system version
eg python script.py >> python2 script.py
Additionally, linking the system version of python to the brew python2 version helped as well:
cd /usr/local/bin && ln -s ../Cellar/python/2.7.13_1/bin/python2 python
I'm also hesitant the accepted answer will work, as pyaml is still attempting to import yaml, via __init__.py; which does not exist even after installing both packages
$ pip install pyaml
Collecting pyaml
Using cached pyaml-17.7.2-py2.py3-none-any.whl
Requirement already satisfied: PyYAML in ~/Library/Python/2.7/lib/python/site-packages (from pyaml)
Installing collected packages: pyaml
Successfully installed pyaml-17.7.2
$ pip install yaml
Collecting yaml
Could not find a version that satisfies the requirement yaml (from versions: )
No matching distribution found for yaml
eg
File "/~/virtualenv/project/lib/python2.7/site-packages/pyaml/__init__.py", line 6, in <module>
import os, sys, io, yaml
Adding modules has been very confusing on my laptop. Whenever I run the pip command, it will appear to be successful – for example:
> pip install selenium
Requirement already satisfied (use --upgrade to upgrade): selenium in /usr/local/lib/python2.7/dist-packages
However, when I try to use it in running python example.py, I get:
Traceback (most recent call last):
File "scriptattempt.py", line 2, in <module>
from selenium import webdriver
ImportError: No module named selenium
Where this happens with pretty much any modules I try to import. Not exactly sure why, I installed python 3 in the past, so I wasn't sure if maybe that's causing problems. I tried python3 example.py, but got the same error for packages in the line before.
I looked in at my site-packages file, at location: /usr/local/lib/python2.7/site-packages
but it's empty. Is this my problem? Is pip not unpacking in the correct location?
I have installed (with lots of troubles) scikits.audiolab for making sounds out of data. Now when I type:
import scikits.audiolab I get the following error
>>> import scikits.audiolab
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/scikits.audiolab-0.11.0-py2.7-macosx-10.7-intel.egg/scikits/audiolab/__init__.py", line 25, in <module>
from pysndfile import formatinfo, sndfile
File "/Library/Python/2.7/site-packages/scikits.audiolab-0.11.0-py2.7-macosx-10.7-intel.egg/scikits/audiolab/pysndfile/__init__.py", line 1, in <module>
from _sndfile import Sndfile, Format, available_file_formats, \
File "numpy.pxd", line 30, in scikits.audiolab.pysndfile._sndfile (/private/tmp/easy_install-gKE3i5/scikits.audiolab-0.11.0/scikits/audiolab/pysndfile/_sndfile.c:9632)
ValueError: numpy.dtype does not appear to be the correct type object
How do I fix this?
Any alternative package that can do the job?
I had the same issue and for me it was caused by installing another (more recent) version of NumPy.
Check if you have different versions of NumPy installed and try switching back to an older one. For my part: I had a system-wide installation of Python and common modules like NumPy, which I couldn't touch because I'm not admin on that system. So when I installed some other library locally (in ~/.local/lib/python2.7/) it would also install more recent versions of SciPy and NumPy and put them into that local folder. And when importing the module it would draw from the local directory first before looking at the system-wide libraries which were working fine before with scikits.audiolab. So for me it was solved by
pip uninstall numy && pip uninstall scipy because that only deleted the newer local versions of numpy.
But more specific to your case, here is a tutorial how (on a Mac) to switch to a certain version of NumPy:
multiple numpy version on Mac OS X
The NumPy version I found working for my scikits.audiolab is 1.6.1
>>> import numpy
>>> numpy.version.version
'1.6.1'
Hope that helps. :)
Maybe you installed/upgraded numpy after installing talkbox. Try running this command:
pip install --upgrade --force-reinstall scikits.talkbox
As suggested here:
https://github.com/ppwwyyxx/speaker-recognition/issues/13