Why can't Anaconda find pdfminer for uninstall? - python

I installed the package pdfminer3k in an Anaconda environment (called "tractatus").
I can load it. Anaconda knows it's there.
$ python
Python 3.7.2 (default, Dec 29 2018, 00:00:04)
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pdfminer
>>>
(tractatus) ~/src/tractatus
$ conda list pdfminer
# packages in environment at /anaconda3/envs/tractatus:
#
# Name Version Build Channel
pdfminer3k 1.3.1 pypi_0 pypi
$ ll /anaconda3/envs/tractatus/lib/python3.7/site-packages/pdfminer3k-1.3.1-py3.7.egg/
total 0
drwxr-xr-x 9 wmcneill staff 288 Feb 4 14:12 EGG-INFO
drwxr-xr-x 26 wmcneill staff 832 Feb 4 14:12 pdfminer
Now I want to delete it, but Anaconda's remove command can't find the package.
$ conda remove pdfminer
Collecting package metadata: done
Solving environment: failed
PackagesNotFoundError: The following packages are missing from the target environment:
- pdfminer
(tractatus) ~/src/tractatus
$ conda remove pdfminer3k
Collecting package metadata: done
Solving environment: failed
PackagesNotFoundError: The following packages are missing from the target environment:
- pdfminer3k
pdfminer also does not appear in the installed packages list shown for this environment in the Anaconda Navigator UI.
Is this a bug in Anaconda, or am I doing something wrong?

Whats is your conda version ?
Do you have multiple environments ?
One possible workaround is try adding the following lines to .condarc file and restarting your system:
channels:
- conda-forge
- anaconda-fusion
- defaults
workaround's source:
https://github.com/conda/conda/issues/6633

I guess when you install pdfminer pkg, you are using 'pip install', so by the time you want to remove it, it can not be found at any of your conda env folder.
Instead of
conda remove pdfminer
try:
pip uninstall pdfminer
It works for me.

Related

Python in R - Error: could not find a Python environment for /usr/bin/python

I don't understand how R handles the Python environment and Python version and keep getting the error Error: could not find a Python environment for /usr/bin/python. I installed Miniconda and created a conda environment in the shell:
conda activate r-reticulate
Then, in R, I try to install keras (same problem with package tensorflow):
library(keras)
reticulate::use_condaenv()
install_keras(method = "conda", conda = reticulate::conda_binary())
... and get the following error:
Error: could not find a Python environment for /usr/bin/python
I tried to figure out what Python R should be using by
reticulate::py_config()
and get
python: /usr/bin/python
libpython: /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config/libpython2.7.dylib
pythonhome: /System/Library/Frameworks/Python.framework/Versions/2.7:/System/Library/Frameworks/Python.framework/Versions/2.7
version: 2.7.16 (default, Jul 5 2020, 02:24:03) [GCC 4.2.1 Compatible Apple LLVM 11.0.3 (clang-1103.0.29.21) (-macos10.15-objc-
numpy: /Users/bestocke/Library/Python/2.7/lib/python/site-packages/numpy
numpy_version: 1.16.6
tensorflow: [NOT FOUND]
python versions found:
/usr/bin/python3
/usr/local/bin/python3
/usr/bin/python
I don't understand this. This seems to be using Python 2.7. When trying to figure out which Python is being used in the shell, I get:
> which python
/opt/miniconda3/envs/r-reticulate/bin/python
and
> ls -l /opt/miniconda3/envs/r-reticulate/bin/python
lrwxr-xr-x 1 username wheel 9 Aug 2 15:21 /opt/miniconda3/envs/r-reticulate/bin/python -> python3.6
Suggesting Python 3.6 should be used.
What am I getting wrong here?
Try to follow the guide at https://tensorflow.rstudio.com/installation/:
In your R-studio console :
install.packages("tensorflow")
library(tensorflow)
install_tensorflow()
If you have not installed Anaconda / Miniconda manually, then at step no. 3, a prompt will ask your permission to install Miniconda. If you already have conda installed, then :
Create new environment r-reticulate in conda : conda create -n r-reticulate
Install tensorflow from R-studio console with parameters : install_tensorflow(method = 'conda', envname = 'r-reticulate')
Load the reticulate package library(reticulate)
Activate the conda environment in R-studio use_condaenv('r-reticulate')
Load the tensorflow libray library(tensorflow)
Check if tensorflow is active tf$constant("Hellow Tensorflow")
References :
https://tensorflow.rstudio.com/installation/
https://rstudio.github.io/reticulate/
I installed using virtualenv, and I found that I have to specify the full path to the env by envname. It does not work by method="virtualenv", envname="r-reticulate"
I hope there is time to add information. I tried to do what Anugerah Erlaut said, but trying to install Keras GPU on R-studio Server, through WSL.
I knew the solution would work because I tried on another computer, but installing on Windows, and Keras CPU. After testing a while (and get frustrated), it seems that Rstudio does not have permissions to change the r-reticulate env.
So, I tried the solution running or "pure R", on bash command line, and it worked just fine!

Can not install VTK with Anaconda

I can not install VTK by anaconda in Mac OS X. I use
conda install -c anaconda vtk=6.3.0
Python 2.7 but get the following error:
UnsatisfiableError: The following specifications were found to be in conflict: - python 3.6* - vtk 6.3.0* -> python 2.7* -> openssl 1.0.1* Use "conda info " to see the dependencies for each package.
But I've updated Python to 3.6, and the same error.
Conda Search
$ conda search vtk
Fetching package metadata ...........
vtk 5.10.1 py27_0 defaults
5.10.1 py27_1 defaults
6.3.0 py27_0 defaults
6.3.0 py27_1 defaults
Create the choicest env
$ conda create -n vtk python=2.7 vtk=6.3.0
Fetching package metadata ...........
Solving package specifications: .
Package plan for installation in environment /home/sidon/opt/anaconda3/envs/vtk:
The following NEW packages will be INSTALLED:
openssl: 1.0.2k-1
pip: 9.0.1-py27_1
python: 2.7.13-0
readline: 6.2-2
setuptools: 27.2.0-py27_0
sqlite: 3.13.0-0
tk: 8.5.18-0
vtk: 6.3.0-py27_1
wheel: 0.29.0-py27_0
zlib: 1.2.8-3
Proceed ([y]/n)? y
vtk-6.3.0-py27 100% |#############################################################################################| Time: 0:00:15 1.97 MB/s
#
# To activate this environment, use:
# > source activate vtk
#
# To deactivate this environment, use:
# > source deactivate vtk
#
Active the new env
$ source activate vtk
Test
$ python -c "import vtk; print vtk.vtkSphereSource()"
vtkSphereSource (0xcfdcc0)
Debug: Off
Modified Time: 39
Reference Count: 2
Registered Events: (none)
Executive: 0xae5e00
ErrorCode: Success
Information: 0xf6e210
AbortExecute: Off
Progress: 0
Progress Text: (None)
Theta Resolution: 8
Phi Resolution: 8
Theta Start: 0
Phi Start: 0
Theta End: 360
Phi End: 180
Radius: 0.5
Center: (0, 0, 0)
LatLong Tessellation: 0
Output Points Precision: 0
I would suggest installing directly from the wheel file. You can get the VTK wheel file from here (wheel file directory site). This site has pretty much every wheel file so it is your friend! just search for it and you will see a bunch of .whl VTK files.
just download the wheel file that matches your anaconda python root version (either 3.5, 3.6, 2.7 etc.) and either 32 or 64 bit (depending on your python version).
To install from a wheel file, open a terminal in the directory the wheel is in and type
pip install "your_wheel_file_name"
If you want to install it for a conda environment, just activate the environment first (activate "env_name") and then install from the wheel file.
Try this out for me:
conda create --name vtk_test python=2.7 vtk
This will create a new environment with VTK, Python and their dependencies inside.

pip not installing numba/llvmlite properly within conda environment

I create a new conda environment
user#machine:~/project$ conda create -n test-env -c numba python=3.5.2 llvmdev=3.8
Fetching package metadata ...........
Solving package specifications: .
Package plan for installation in environment /home/user/anaconda2/envs/test-env:
The following NEW packages will be INSTALLED:
llvmdev: 3.8.1-7 numba
openssl: 1.0.2k-0
pip: 9.0.1-py35_1
python: 3.5.2-0
readline: 6.2-2
setuptools: 27.2.0-py35_0
sqlite: 3.13.0-0
system: 5.8-2 numba
tk: 8.5.18-0
wheel: 0.29.0-py35_0
xz: 5.2.2-1
zlib: 1.2.8-3
Proceed ([y]/n)? y
#
# To activate this environment, use:
# > source activate test-env
#
# To deactivate this environment, use:
# > source deactivate test-env
#
and then activate it and attempt to use specifically pip (not conda) to install llvmlite and numba, which appears to succeed. (Note: I've tried also --no-cache-dir and it doesn't change anything.)
user#machine:~/project$ source activate test-env
(test-env) user#machine:~/project$ pip install llvmlite==0.15 numba==0.30.1
Collecting llvmlite==0.15
Collecting numba==0.30.1
Collecting numpy (from numba==0.30.1)
Using cached numpy-1.12.0-cp35-cp35m-manylinux1_x86_64.whl
Installing collected packages: llvmlite, numpy, numba
Successfully installed llvmlite-0.15.0 numba-0.30.1 numpy-1.12.0
But the library is not installed properly,
(test-env) user#machine:~/project$ python
Python 3.5.2 |Continuum Analytics, Inc.| (default, Jul 2 2016, 17:53:06)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numba
Traceback (most recent call last):
File "/home/user/anaconda2/envs/test-env/lib/python3.5/site-packages/llvmlite/binding/ffi.py", line 42, in <module>
lib = ctypes.CDLL(os.path.join(_lib_dir, _lib_name))
File "/home/user/anaconda2/envs/test-env/lib/python3.5/ctypes/__init__.py", line 347, in __init__
self._handle = _dlopen(self._name, mode)
OSError: /home/user/anaconda2/envs/test-env/lib/python3.5/site-packages/llvmlite/binding/libllvmlite.so: undefined symbol: _ZNKSt14error_category23default_error_conditionEi
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/user/anaconda2/envs/test-env/lib/python3.5/site-packages/numba/__init__.py", line 9, in <module>
from . import config, errors, runtests, types
File "/home/user/anaconda2/envs/test-env/lib/python3.5/site-packages/numba/config.py", line 11, in <module>
import llvmlite.binding as ll
File "/home/user/anaconda2/envs/test-env/lib/python3.5/site-packages/llvmlite/binding/__init__.py", line 6, in <module>
from .dylib import *
File "/home/user/anaconda2/envs/test-env/lib/python3.5/site-packages/llvmlite/binding/dylib.py", line 4, in <module>
from . import ffi
File "/home/user/anaconda2/envs/test-env/lib/python3.5/site-packages/llvmlite/binding/ffi.py", line 47, in <module>
lib = ctypes.CDLL(_lib_name)
File "/home/user/anaconda2/envs/test-env/lib/python3.5/ctypes/__init__.py", line 347, in __init__
self._handle = _dlopen(self._name, mode)
OSError: libllvmlite.so: cannot open shared object file: No such file or directory
Why does the conda installation of llvmdev from the numba channel fail to "just work".
In my use case, I'm coming to a project that has a pip-styled requirements.txt file, and I need to create conda environments from that file. Some project developers will use venv+pip, some will use conda, and some packages it contains are not found in any anaconda channels, so pip installation is mandatory. We don't want to maintain a separate envrionment.yaml in addition to the requirements.txt, so installing from requirements.txt inside of a conda envrionment is part of my constraints.
Everything seems OK, except for the pip installation of numba/llvmlite, which expects a system dependency of llvm 3.8+. I want to satisfy that as part of the conda environment though.
How can I ensure from a conda environment only that the right llvmdev exists for installing numba and llvmlite?
Installing llvmdev:
Installing llvmdev from the conda-forge channel can be achieved by adding conda-forge to your channels with:
conda config --add channels conda-forge
Once the conda-forge channel has been enabled, llvmdev can be installed with:
conda install llvmdev
It is possible to list all of the versions of llvmdev available on your platform with:
conda search llvmdev --channel conda-forge
HELP:I cloned the relevant files from their GitHub sources and did
python setup.py install
for more without conda use pip
sudo pip install -U llvmlite
sudo pip install -U numba
This is what worked for me using the Anaconda environment:
pip uninstall llvmlite
pip install -U --ignore-installed numba
In an ideal scenario, the required shared library should be present after the installation of llvmlite.
(test-env) ~/condaexpts$ conda create -n test-env -c numba python=3.5.2 llvmdev=3.8
(test-env) ~/condaexpts$ source activate test-env
(test-env) ~/condaexpts$ pip install numpy==1.12.0 llvmlite==0.15 numba==0.30.1
(test-env) ~/condaexpts$ find $CONDA_PREFIX | grep libllvmlite
/home/ubuntu/condaexpts/m3/envs/test-env/lib/python3.5/site-packages/llvmlite/binding/libllvmlite.so
If this file is not present in the test-env, then something went wrong while installing llvmlite.
Also, think about this approach the other way round. You don't need to have a requirements file separate from conda environment file. You can have both dependencies in the conda environment file itself:
(test-env) ~/condaexpts$ conda env export
name: test-env
channels:
- !!python/unicode
'numba'
- !!python/unicode
'defaults'
dependencies:
- !!python/unicode
'openssl=1.0.2k=0'
- !!python/unicode
'pip=9.0.1=py35_1'
- !!python/unicode
'python=3.5.2=0'
- !!python/unicode
'readline=6.2=2'
- !!python/unicode
'setuptools=27.2.0=py35_0'
- !!python/unicode
'sqlite=3.13.0=0'
- !!python/unicode
'tk=8.5.18=0'
- !!python/unicode
'wheel=0.29.0=py35_0'
- !!python/unicode
'xz=5.2.2=1'
- !!python/unicode
'zlib=1.2.8=3'
- !!python/unicode
'llvmdev=3.8.1=7'
- !!python/unicode
'system=5.8=2'
- pip:
- llvmlite==0.15.0
- numba==0.30.1
- numpy==1.12.0
prefix: !!python/unicode '/home/ubuntu/condaexpts/m3/envs/test-env'
On second note, you can install the pre-built binaries required from the 'numba' conda channel itself. With:
(root) ~/condaexpts$ ./Miniconda3-latest-Linux-x86_64.sh -b -p m3
(root) ~/condaexpts$ source ./m3/bin/activate
(root) ~/condaexpts$ conda create -n test-env -c numba python=3.5.2 llvmdev=3.8 numba=0.30.1 llvmlite=0.15.0
(root) ~/condaexpts$ source activate test-env
(test-env) ~/condaexpts$ python
Python 3.5.2 |Continuum Analytics, Inc.| (default, Jul 2 2016, 17:53:06)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numba
>>> numba.__version__
'0.30.1'

ImportError when using Python Anaconda package grib_api

I am trying to use the ECMWF GRIB_API to access GRIB files from Python. I get this error
Traceback (most recent call last):
File "/home/martin/markj/JustImportGRIB.py", line 1, in <module>
from gribapi import *
ImportError: No module named gribapi
One line of code :)
from gribapi import *
I am using Anaconda Python 2.7.12, Linux Centos 64-bit, installed as user and not added Anaconda to the path if that's relevant - the system Python (2.6) is on the path. I installed GRIB_API from the Pingu Carsti channel which was the top Google hit. The conda install did not report any errors.
[martin#bonnie ~]$ anaconda2/bin/conda install -c pingucarsti grib_api=1.10.4
Fetching package metadata .........
Solving package specifications: ..........
Package plan for installation in environment /home/martin/anaconda2:
The following packages will be downloaded:
package | build
---------------------------|-----------------
grib_api-1.10.4 | 3 1.7 MB pingucarsti
The following NEW packages will be INSTALLED:
grib_api: 1.10.4-3 pingucarsti
Proceed ([y]/n)? y
Fetching packages ...
grib_api-1.10. 100% |################################| Time: 0:00:01 1.24 MB/s
Extracting packages ...
[ COMPLETE ]|###################################################| 100%
Linking packages ...
[ COMPLETE ]|###################################################| 100%
I found some bug reports about this error being caused by a bug in the ECMWF GRIB_API, but I don't know enough about Anaconda (or perhaps Python) to figure out how to apply the workarounds.
I read GRIB files in Python with pygrib. I have successfully installed it inside a conda virtual environment (Miniconda2 on Ubuntu 16.04). Here is what has worked for me:
Install system dependencies for pygrib:
sudo apt-get install libjpeg9
sudo apt-get install libgrib-api-dev
Install pygrib and ecmwf_grib from conda-forge channel.
conda install -c conda-forge pygrib ecmwf_grib
Try conda-forge's build at python-eccodes (note: that's not eccodes which is the C library).
How it is built: https://github.com/conda-forge/python-eccodes-feedstock/blob/master/recipe/meta.yaml
The ECMWF's ecCodes library is the next version of their GRIB API, and is extremely similar to the old GRIB API.
pelson> conda create -n gribby -c conda-forge python-eccodes
Fetching package metadata .............
Solving package specifications: .
Package plan for installation in environment /Users/pelson/miniconda/envs/gribby:
The following NEW packages will be INSTALLED:
ca-certificates: 2017.7.27.1-0 conda-forge
curl: 7.54.1-0 conda-forge
eccodes: 2.4.0-0 conda-forge
hdf4: 4.2.12-0 conda-forge
hdf5: 1.8.18-1 conda-forge
intel-openmp: 2018.0.0-h68bdfb3_7 defaults
jasper: 1.900.1-4 conda-forge
jpeg: 9b-1 conda-forge
krb5: 1.14.2-0 conda-forge
libgfortran: 3.0.1-h93005f0_2 defaults
libnetcdf: 4.4.1.1-8 conda-forge
libpng: 1.6.28-1 conda-forge
libssh2: 1.8.0-1 conda-forge
mkl: 2018.0.0-h5ef208c_6 defaults
ncurses: 5.9-10 conda-forge
numpy: 1.13.3-py27h62f9060_0 defaults
openssl: 1.0.2l-0 conda-forge
python: 2.7.14-0 conda-forge
python-eccodes: 2.4.0-py27_1 conda-forge
readline: 6.2-0 conda-forge
sqlite: 3.13.0-1 conda-forge
tk: 8.5.19-2 conda-forge
zlib: 1.2.8-3 conda-forge
#
# To activate this environment, use:
# > source activate gribby
#
# To deactivate an active environment, use:
# > source deactivate
#
pelson> source activate gribby
python(gribby) pelson> python
Python 2.7.14 | packaged by conda-forge | (default, Oct 5 2017, 23:08:53)
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import gribapi
>>> gribapi.__version__
'2.4.0'

Install GDAL in virtualenvwrapper environment

I tried to install gdal (pip install gdal)in virtualenvwrapper environment but I got this error :
error: command 'gcc' failed with exit status 1
----------------------------------------
Failed building wheel for gdal
Failed to build gdal
I tried also "pip install --no-install GDAL" but there is nooption --no-install
what should I do !?
Yes, installing GDAL in a venv is a doozy. Conveniently, I just wrote up the documentation on how to do so for my advisor's lab! While I am not savvy enough to pinpoint the exact cause of your error, I can give you a bunch of things to try to fix it.
First, ensure you have gdal installed on the host (i.e. not in a venv). I just run the following:
sudo apt-get install libgdal1i libgdal1-dev libgdal-dev
Now run gdal-config --version to get the version that apt-get provided you with. For example I get 1.11.3
Now, the easiest way in my experience to get the python bindings in a venv is using pygdal. The trick is to get the right version! To do so, activate your virtual environment and run
pip install pygdal==1.11.3
but replace the version with whatever you got from gdal-config --version. Note: you may get an error that says
Could not find a version that satisfies the requirement pygdal==1.11.3 (from versions: 1.8.1.0, 1.8.1.1, 1.8.1.2, 1.8.1.3, 1.9.2.0, 1.9.2.1, 1.9.2.3, 1.10.0.0, 1.10.0.1, 1.10.0.3, 1.10.1.0, 1.10.1.1, 1.10.1.3, 1.11.0.0, 1.11.0.1, 1.11.0.3, 1.11.1.0, 1.11.1.1, 1.11.1.3, 1.11.2.1, 1.11.2.3, 1.11.3.3, 1.11.4.3, 2.1.0.3) No matching distribution found for pygdal==1.11.3
If that happens, run the pip install again but with the highest version that still matches. e.g. in this case you would run pip install pygdal==1.11.3.3
Once pygdal has been successfully installed, you should be able to call
>>> from osgeo import gdal
Please let me know if anything fails and I'll do what I can to adjust my instructions. Also, if you need help with Proj.4, GEOS, or Cartopy, I have some experience there too.
use pygdal
pd#asghar:~$sudo apt-get install python3-gdal
pd#asghar:~$ virtualenv -p python3 test
Running virtualenv with interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in /home/pd/test/bin/python3
Also creating executable in /home/pd/test/bin/python
Installing setuptools, pip, wheel...done.
pd#asghar:~$ gdal-config --version
2.1.3
pd#asghar:~$ test/bin/pip install pygdal==2.1.3
Collecting pygdal==2.1.3
Could not find a version that satisfies the requirement pygdal==2.1.3 (from versions: 1.8.1.0, 1.8.1.1, 1.8.1.2, 1.8.1.3, 1.9.2.0, 1.9.2.1, 1.9.2.3, 1.10.0.0, 1.10.0.1, 1.10.0.3, 1.10.1.0, 1.10.1.1, 1.10.1.3, 1.11.0.0, 1.11.0.1, 1.11.0.3, 1.11.1.0, 1.11.1.1, 1.11.1.3, 1.11.2.1, 1.11.2.3, 1.11.3.3, 1.11.4.3, 1.11.5.3, 2.0.0.3, 2.0.1.3, 2.0.2.3, 2.0.3.3, 2.1.0.3, 2.1.1.3, 2.1.2.3, 2.1.3.3, 2.2.0.3)
No matching distribution found for pygdal==2.1.3
pd#asghar:~$ test/bin/pip install pygdal==2.1.3.3
Collecting pygdal==2.1.3.3
Collecting numpy>=1.0.0 (from pygdal==2.1.3.3)
Using cached numpy-1.13.1-cp35-cp35m-manylinux1_x86_64.whl
Installing collected packages: numpy, pygdal
Successfully installed numpy-1.13.1 pygdal-2.1.3.3
pd#asghar:~$ source test/bin/activate
(test) pd#asghar:~$ python
Python 3.5.2 (default, Nov 17 2016, 17:05:23)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from osgeo import gdal
>>>
On MacOS, first do brew install:
brew install gdal
Then do pip install:
pip install gdal

Categories