Can't find Python modules after Time Machine restore - numpy

Recently, I performed a clean install of OS X Mountain Lion and restored my system from a Time Machine backup. When I tried to use python, it was unable to find most of the modules that I had installed before I wiped my OS. It also appears that the Xcode Command Line Tools were no longer on the system.
I reinstalled the Xcode Command Line Tools and pip (using easy_install), and went to work reinstalling the modules I use, starting with numpy. However, pip said it was already installed:
Requirement already satisfied (use --upgrade to upgrade): numpy in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
However, in the CLI for Python, it still can't find numpy:
Python 2.7.3 (v2.7.3:70274d53c1dd, Apr 9 2012, 20:52:43)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named numpy
I've tried to install some other modules. When I installed ujson with pip, everything went fine, and python found it with no problems. However, when I tried to install matplotlib with pip, clang threw an error and it failed to install. I think the problem might be that matplotlib has dependency on numpy, but I don't know.
In file included from src/ft2font.cpp:3:
src/ft2font.h:16:10: fatal error: 'ft2build.h' file not found
#include <ft2build.h>
^
1 error generated.
error: command 'clang' failed with exit status 1
----------------------------------------
Command /usr/bin/python -c "import setuptools;__file__='/tmp/pip-build/matplotlib/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-lqNcmF-record/install-record.txt --single-version-externally-managed failed with error code 1 in /tmp/pip-build/matplotlib`
Any advice on how to resolve this issue? Should I just uninstall this other version of numpy, or do you think this is a deeper issue?

Deleting the numpy files in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python and reinstalling numpy would be my suggestion. It seems like the libraries are no longer being linked to properly even though the files are there.

Related

Failed to import cupy

After installing cupy via "pip install cupy-cuda110", I tried this in python3:
import cupy as cp
However, it failed:
"
$ python3
Python 3.8.10 (default, Nov 26 2021, 20:14:08)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
import cupy as cp
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/cupy/init.py", line 18, in
from cupy import _core # NOQA
File "/usr/local/lib/python3.8/dist-packages/cupy/_core/init.py", line 1, in
from cupy._core import core # NOQA
ImportError: libnvrtc.so.11.0: cannot open shared object file: No such file or directory
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.8/dist-packages/cupy/init.py", line 20, in
raise ImportError(f'''
ImportError:
Failed to import CuPy.
If you installed CuPy via wheels (cupy-cudaXXX or cupy-rocm-X-X), make sure that the package matches with the version of CUDA or ROCm installed.
On Linux, you may need to set LD_LIBRARY_PATH environment variable depending on how you installed CUDA/ROCm.
On Windows, try setting CUDA_PATH environment variable.
Check the Installation Guide for details:
https://docs.cupy.dev/en/latest/install.html
Original error:
ImportError: libnvrtc.so.11.0: cannot open shared object file: No such file or directory
"
May you know how to resolve this problem? Many thanks!
Before installing cupy, you should check the version of Cuda that is installed on your device :
!nvcc --version
For me, the Cuda version installed on my device is 11.0 (See the picture below) :
After that go to the official Cupy website https://docs.cupy.dev/en/stable/install.html
The following image is from the page I referred to above:
Then type the install command that matches your Cuda version, for me, the install command will be :
pip install cupy-cuda110
When installing these packages with CUDA 11.2, 11.3, or 11.4, you may experience a “Failed to import CuPy” error. To resolve this error, please uninstall cupy-cuda115 and install cupy-cuda11x:
pip uninstall cupy-cuda115
pip install cupy-cuda11x
https://rapids.ai/pip.html

Building Tensorflow 2.0 from source

I've built Tensorflow 2.0 from source using the below commands:
-march=native -Wno-sign-compare -mssse3 -mcx16 -msse4.1 -msse4.2 -mpopcnt -mno-avx
bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package --local_ram_resources=1024 --jobs=1 --define=tf_api_version=2
The build apparently completed successfully, that is without any errors, but when I go to install, using the below command:
python /tensorflow/tools/pip_package/setup.py install
It installs the egg in site-packages and checks for dependencies, but does nothing else. Nor does it return any error. The end of the output is below:
Searching for Markdown==3.1.1
Best match: Markdown 3.1.1
Adding Markdown 3.1.1 to easy-install.pth file
Installing markdown_py script to /var/...
Using /var/.../python3.6/site-packages
Searching for h5py==2.9.0
Best match: h5py 2.9.0
Adding h5py 2.9.0 to easy-install.pth file
Using /var/.../python3.6/site-packages
Finished processing dependencies for tensorflow==2.0.0rc0
and of course when I run python:
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'tensorflow'
What am I missing here?
I could not comment at the moment. Can you verify the installation is done successfully ? That is after running:
python /tensorflow/tools/pip_package/setup.py install
you can check the folder tensorflow package in Python lib folders.

TensorFlow pip installation issue: cannot import name 'descriptor'

I'm seeing the following error when installing TensorFlow:
ImportError: Traceback (most recent call last):
File ".../graph_pb2.py", line 6, in
from google.protobuf import descriptor as _descriptor
ImportError: cannot import name 'descriptor'
This error signals a mismatch between protobuf and TensorFlow versions.
Take the following steps to fix this error:
Uninstall TensorFlow.
Uninstall protobuf (if protobuf is installed).
Reinstall TensorFlow, which will also install the correct protobuf dependency.
I faced the similar issue, after trial and error, I used the below logic to run the program:
pip install --upgrade --no-deps --force-reinstall tensorflow
This will make sure to uninstall and reinstall the program from fresh. It works!
I would be extra careful before uninstalling/reinstalling other packages such as protobuf. What I think would most likely be the issue is difference in versions. As of writing this, the most recent release of python is 3.7 while tensorflow is only compatible up to 3.6.
If you're using a 3rd party distribution like Anaconda, this can get hidden from you. In this case I would recommend creating a new environment in Anaconda, with python 3.6 and then installing tensorflow: https://conda.io/projects/conda/en/latest/user-guide/getting-started.html#managing-python
Try this:
pip uninstall protobuf
brew install protobuf
mkdir -p
/Users/alexeibendebury/Library/Python/2.7/lib/python/site-packages
echo 'import site;
site.addsitedir("/usr/local/lib/python2.7/site-packages")' >>
/Users/alexeibendebury/Library/Python/2.7/lib/python/site-packages/homebrew.pth

Install matplotlib with Plone 4.3.3 via buildout [duplicate]

When I try to upgrade my matplotlib using pip, it outputs:
Downloading/unpacking matplotlib from https://pypi.python.org/packages/source/m/matplotlib/matplotlib-1.4.0.tar.gz#md5=1daf7f2123d94745feac1a30b210940c
Downloading matplotlib-1.4.0.tar.gz (51.2MB): 51.2MB downloaded
Running setup.py (path:/tmp/pip_build_root/matplotlib/setup.py) egg_info for package matplotlib
============================================================================
Edit setup.cfg to change the build options
BUILDING MATPLOTLIB
matplotlib: yes [1.4.0]
python: yes [2.7.6 (default, Mar 22 2014, 22:59:38) [GCC
4.8.2]]
platform: yes [linux2]
REQUIRED DEPENDENCIES AND EXTENSIONS
numpy: yes [version 1.8.2]
six: yes [using six version 1.7.3]
dateutil: yes [using dateutil version 2.2]
tornado: yes [using tornado version 4.0.1]
pyparsing: yes [using pyparsing version 2.0.2]
pycxx: yes [Couldn't import. Using local copy.]
libagg: yes [pkg-config information for 'libagg' could not
be found. Using local copy.]
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/tmp/pip_build_root/matplotlib/setup.py", line 154, in <module>
result = package.check()
File "setupext.py", line 940, in check
if 'No such file or directory\ngrep:' in version:
TypeError: argument of type 'NoneType' is not iterable
Complete output from command python setup.py egg_info:
============================================================================
Edit setup.cfg to change the build options
BUILDING MATPLOTLIB
matplotlib: yes [1.4.0]
python: yes [2.7.6 (default, Mar 22 2014, 22:59:38) [GCC
4.8.2]]
platform: yes [linux2]
REQUIRED DEPENDENCIES AND EXTENSIONS
numpy: yes [version 1.8.2]
six: yes [using six version 1.7.3]
dateutil: yes [using dateutil version 2.2]
tornado: yes [using tornado version 4.0.1]
pyparsing: yes [using pyparsing version 2.0.2]
pycxx: yes [Couldn't import. Using local copy.]
libagg: yes [pkg-config information for 'libagg' could not
be found. Using local copy.]
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/tmp/pip_build_root/matplotlib/setup.py", line 154, in <module>
result = package.check()
File "setupext.py", line 940, in check
if 'No such file or directory\ngrep:' in version:
TypeError: argument of type 'NoneType' is not iterable
----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_root/matplotlib
Storing debug log for failure in /home/username/.pip/pip.log
In the tail of the log it says:
Exception information:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/pip-1.5.6-py2.7.egg/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/usr/local/lib/python2.7/dist-packages/pip-1.5.6-py2.7.egg/pip/commands/install.py", line 278, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File "/usr/local/lib/python2.7/dist-packages/pip-1.5.6-py2.7.egg/pip/req.py", line 1229, in prepare_files
req_to_install.run_egg_info()
File "/usr/local/lib/python2.7/dist-packages/pip-1.5.6-py2.7.egg/pip/req.py", line 325, in run_egg_info
command_desc='python setup.py egg_info')
File "/usr/local/lib/python2.7/dist-packages/pip-1.5.6-py2.7.egg/pip/util.py", line 697, in call_subprocess
% (command_desc, proc.returncode, cwd))
InstallationError: Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_root/matplotlib
Why did it fail?
Many thanks!
This is a known bug that has been fixed (https://github.com/matplotlib/matplotlib/pull/3414) on master.
The bug is in the handling of searching for a freetype installation. If you install the Linux package freetype-dev, you will avoid this bug and be able to compile matplotlib.
sudo apt-get install libfreetype6-dev
On Ubuntu 14 server, you also need to install libxft-dev
sudo apt-get install libfreetype6-dev libxft-dev
I had the same issues trying to install matplotlib on Python 3 using pip3, and it seems that this problem is related to a bare-bones installation of Python 3, and doing a:
sudo apt-get build-dep matplotlib
followed by
sudo pip3 install matplotlib
is probably a better solution than selectively installing only the libraries related to matplotlib.
Since mac doesn't have apt-get you, on OSX you may need to do:
brew install freetype
then you can run:
pip install matplotlib
Found this page while looking answer for fedora 24.
RPM solution is:
dnf install freetype-devel
If you re running Ubuntu server 14.04 u should add this font dependency
sudo apt-get install libxft-dev
Source
I was trying too update directly using sudo pip but changes are not saved in last. So i first use update cmd in terminal:
sudo apt-get update
then i used sudo install:
sudo apt-get install libffi-dev
Finally its installed by doing this method.
For those on Fedora 25 hitting this thread, I needed these two packages to make it work:
sudo dnf install freetype-devel gcc-c++
This worked for me:
python -m pip install -U pip setuptools
python -m pip install matplotlib
For more details, follow : https://matplotlib.org/2.0.0/users/installing.html

lxml on python-3.3.0 ImportError: undefined symbol: xmlBufContent

I am having a hard time installing lxml(3.1.0) on python-3.3.0. It installs without errors and I can see the lxml-3.1.0-py3.3-linux-i686.egg in the correct folder (/usr/local/lib/python3.3/site-packages/), but when I try to import etree, I get this:
from lxml import etree
Traceback (most recent call last):
File "", line 1, in
ImportError: /usr/local/lib/python3.3/site-packages/lxml-3.1.0-py3.3-linux-i686.egg/lxml/etree.cpython-33m.so: undefined symbol: xmlBufContent
I did try to install with apt-get, I tried "python3 setup.py install" and I did via easy_install. I have to mention that I have 3 versions installed (2.7, 3.2.3 and 3.3.0.), but I am too much of a beginner to tell if this has to do with it.
I did search all over, but I could not find any solution to this.
Any help is greatly appreciated!
best,
Uhru
You should probably mention the specific operating system you're trying to install on, but I'll assume it's some form of Linux, perhaps Ubuntu or Debian since you mention apt-get.
The error message you mention is typical on lxml when the libxml2 and/or libxslt libraries are not installed for it to link with. For whatever reason, the install procedure does not detect when these are not present and can give the sense the install has succeeded even though those dependencies are not satisfied.
If you issue apt-get install libxml2 libxml2-dev libxslt libxslt-dev that should eliminate this error.