I have installed (and uninstalled) and installed GDAL 2.2.2 in Windows 10 using Christoph wheel. However, when I try to import it I get:
Installing collected packages: GDAL
Successfully installed GDAL-2.2.2
(e4) C:\Users\R1702898\Documents\Empirical_v4>python
Python 3.4.4 |Continuum Analytics, Inc.| (default, Jun 15 2016, 15:25:08)
[MSC v.1600 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from osgeo import ogr
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\R1702898\Documents\e4\lib\site-packages\osgeo\__init__.py", line 35, in <module>
_gdal = swig_import_helper()
File "C:\Users\R1702898\Documents\e4\lib\site-packages\osgeo\__init__.py", line 31, in swig_import_helper
_mod = imp.load_module('_gdal', fp, pathname, description)
File "C:\Users\R1702898\Documents\e4\lib\imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
ImportError: DLL load failed with error code -1073741795
The only way it is possible to install in Windows is using the wheels. All else fails. The only available wheel is for version 2.2.2
All other dependencies: Fiona, six, numpy, pandas are installed. Although geopandas won't import either (because it needs ogr). I have also set the path to the bin.
Any help. Please. Thanks.
One of the things i would avoid is to mix and match different ways of installing. If you are using Conda already, stick to it. I only use pip install as a last resort. Because GDAL uses compiled code, it can get messy if you install packages relying on GDAL which are build with different compilers, something you probably are encountering. That's exactly what Conda solves by carefully looking at requirements and dependencies.
In your case, part of the difficulty comes from using Fiona, although its a great package, they have some very strict version requirements making it not the easiest dependency to have. See the yaml from Conda-Forge:
https://github.com/conda-forge/fiona-feedstock/blob/master/recipe/meta.yaml
On my machine (Win 10 64bit) its still possible to get all packages you list above by only using Conda,
My approach would be:
1) Update your Conda to a recent version (conda update conda -n root)
2) Create a new environment:
conda create -n gdaltest python=3.6 gdal fiona geopandas numpy -c conda-forge
Because of the restrictions in some of the recipes, it solves (for me) to using for example Numpy 1.11, instead of the latest 1.13.
3) Activate the new environment (activate gdaltest) and check if the activation script has worked. That should set the environment variables correctly, this is an important step when it comes to conflicts.
In cmd run SET and check if GDAL_DATA is set to the environment you just activated. Also check if your activate environment comes first in the PATH variable, it should have added several folders from your environment (like ..\Library\bin, ..\Scripts etc).
That should be sufficient. You can check it by starting Python (make sure the correct environment is active) and start importing gdal, fiona etc.
Related
For python 3.8.8 and using the new mac air (with the m1 chip), in jupyter notebooks and in python terminal, import jax raises this error
Python 3.8.8 (default, Apr 13 2021, 12:59:45)
[Clang 10.0.0 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import jax
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/steve/Documents/code/jax/jax/__init__.py", line 37, in <module>
from . import config as _config_module
File "/Users/steve/Documents/code/jax/jax/config.py", line 18, in <module>
from jax._src.config import config
File "/Users/steve/Documents/code/jax/jax/_src/config.py", line 26, in <module>
from jax import lib
File "/Users/steve/Documents/code/jax/jax/lib/__init__.py", line 63, in <module>
cpu_feature_guard.check_cpu_features()
RuntimeError: This version of jaxlib was built using AVX instructions, which your CPU and/or operating system do not support. You may be able work around this issue by building jaxlib from source.
I suspect it occurs because of the m1 chip.
I tried using jax with pip install jax, then I built it from source as suggested by the comment, by cloning their repository and following the instructions given here, but the same error message shows.
Thanks #jakevdp I looked at the issue you linked and found a workaround :
Thanks to Noah who mentioned in issue #5501 that you could just use a previous version of jax and jaxlib, for my purposes jaxlib==0.1.60 and jax==0.2.10 work just fine!
JAX does not yet provide pre-built jaxlib wheels that are compatible with M1 chips. The best source of information I know on building jaxlib on M1 is probably this github issue: https://github.com/google/jax/issues/5501, which also tracks improving this support.
Hopefully M1 support will be improved in the near future, but it's taking a while for the scientific computing infrastructure up and down the stack to catch up with the requirements of the new chips.
I had a similar problem. Since I already had Anaconda installed and didn't want to clutter up my space with Anaconda + miniconda + homebrew versions of python and package management and whatever, I hunted around for a simple solution. What ended up working for me was first uninstalling jax and jaxlib and then installing jax and jaxlib via conda-forge directly:
pip uninstall jax jaxlib
conda install -c conda-forge jaxlib
conda install -c conda-forge jax
As of now (January 2022), jax is available for M1 Macs. Make sure to uninstall jax and jaxlib and then install the new packages via pip:
pip install --upgrade jax jaxlib
Afterwards, you can use jax without problems.
--Edit--
I am running on a machine with the following specs:
ProductName: macOS
ProductVersion: 12.1
BuildVersion: 21C52
and with Python 3.9.6 within a conda environment.
I am trying to install Numba on a cluster so I can run my Jitted python codes on there. However I keep running into an error with "libllvmlite.so" when I try to import Numba. This is done on the Cedar cluster using virtualenv. Numba is installed using pip (and also tried pip3).
I start off my activating my enviroment using (... is the directory to my enviroment folder) :
source ~/.../ENV/bin/activate.
Then I use pip to install Numba (I've also tried used pip uninstall to remove and reinstall Numba).
However when I load up Python 3.7.0 on my enviroment, I obtain an error whenever I try to import Numba.
I use pip show to check versions: Python 3.7.0, Numba 0.53.1, llvmlite 0.36.0.
Here is the output of my terminal:
(ENV) [04:12:46] patrick7#cedar1 > [~/projects/def-mann/patrick7/diffusioncluster]python
Python 3.7.0 (default, Sep 25 2018, 18:19:16)
[GCC 5.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numba
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/patrick7/projects/def-mann/patrick7/diffusioncluster/ENV/lib/python3.7/site-packages/numba/__init__.py", line 19, in <module>
from numba.core import config
File "/home/patrick7/projects/def-mann/patrick7/diffusioncluster/ENV/lib/python3.7/site-packages/numba/core/config.py", line 16, in <module>
import llvmlite.binding as ll
File "/home/patrick7/projects/def-mann/patrick7/diffusioncluster/ENV/lib/python3.7/site-packages/llvmlite/binding/__init__.py", line 4, in <module>
from .dylib import *
File "/home/patrick7/projects/def-mann/patrick7/diffusioncluster/ENV/lib/python3.7/site-packages/llvmlite/binding/dylib.py", line 3, in <module>
from llvmlite.binding import ffi
File "/home/patrick7/projects/def-mann/patrick7/diffusioncluster/ENV/lib/python3.7/site-packages/llvmlite/binding/ffi.py", line 191, in <module>
raise OSError("Could not load shared object file: {}".format(_lib_name))
OSError: Could not load shared object file: libllvmlite.so
I have tried other solutions found online (reinstall, try different versions...), so far none has worked. Any help would be greatly appreciated! Thanks!
I figured out the solution to my problem.
What I've tried and didn't work:
Install llvmlite using pip manually
Downgrade to Numba version 0.43 since its the oldest version compatible with Python 3.7
Uninstall (llvmlite numpy and numba) and reinstalling Numba (which automatically installs it's dependancies) after upgrading Pip to the latest version
What worked:
Upgrading Python from 3.7.0 to 3.7.10
It seems like for Python version >= 3.7.3, the default command pip install numba works flawlessly!
Thanks for reading!
Do you know how I could fix this? I am trying to use https://github.com/benjiebob/SMALViewer/issues/3 repo however I get error on neural_renderer port:
$ python smal_viewer.py
Traceback (most recent call last):
File "smal_viewer.py", line 2, in <module>
import pyqt_viewer
File "/home/mona/research/3danimals/SMALViewer/pyqt_viewer.py", line 13, in <module>
from smal.smal3d_renderer import SMAL3DRenderer
File "/home/mona/research/3danimals/SMALViewer/smal/smal3d_renderer.py", line 6, in <module>
import neural_renderer as nr
File "/home/mona/anaconda3/lib/python3.7/site-packages/neural_renderer/__init__.py", line 3, in <module>
from .load_obj import load_obj
File "/home/mona/anaconda3/lib/python3.7/site-packages/neural_renderer/load_obj.py", line 8, in <module>
import neural_renderer.cuda.load_textures as load_textures_cuda
ImportError: /home/mona/anaconda3/lib/python3.7/site-packages/neural_renderer/cuda/load_textures.cpython-37m-x86_64-linux-gnu.so: undefined symbol: THPVariableClass
Here is some details:
$ python
Python 3.7.6 (default, Jan 8 2020, 19:59:22)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.__version__
'1.6.0'
>>> torch.version.cuda
'10.1'
>>> torch.cuda.is_available()
True
$ gcc --version
gcc (Ubuntu 9.3.0-10ubuntu2) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ lsb_release -a
LSB Version: core-11.1.0ubuntu2-noarch:security-11.1.0ubuntu2-noarch
Distributor ID: Ubuntu
Description: Ubuntu 20.04.1 LTS
Release: 20.04
Codename: focal
Here is the neural renderer git repo: https://github.com/daniilidis-group/neural_renderer
I installed the neural renderer using pip install neural_renderer_pytorch
It looks like you didn't build the neural_renderer_pytorch yourself, but used a wheel. However, this wheel was built with an older pytorch version and doesn't work with the current pytorch version on your machine.
Build neural_renderer from the source (after deinstalling neural_renderer you have now) using your current pytorch-version i.e.
$ pip uninstall neural-renderer-pytorch
$ pip install https://github.com/daniilidis-group/neural_renderer/zipball/master
and it should work.
Until pytorch 1.5, it used a someway brittle way of building extensions on Linux: despite depending on torch, extensions didn't link explicitly against libtorch.so. The missing symbols were provided only because import torch loaded libtorch.so with RTLD_GLOBAL, thus making its symbols globally visibile/accessible - this is the reason why prior to loading those extensions (e.g. neural_renderer_pytorch like here) one had to import torch.
One could enforce the old behavior setting RTLD_GLOBAL prior to importing torch for the very first time it is happening:
import sys; import ctypes;
sys.setdlopenflags(sys.getdlopenflags() | ctypes.RTLD_GLOBAL)
import torch # now all symbols of torch
# have global visibility and can be used in
# other extensions
However, using RTLD_GLOBAL is quite dangerous as it could possibly interpose symbols that are unrelated and lead to subtle bugs or even crashes.
Thus, since 1.5 pytorch no longer uses RTLD_GLOBAL, but links explicitly against libpytorch.so (see this commit) and extensions built with older pytorch versions will not work.
I was able to fix this by first finding all the AT_CHECK and converting them to AT_ASSERT. Checking out the at_assert_fix branch didn't solve the problem for me. I am using PyTorch 1.6 and CUDA 10.1
https://github.com/daniilidis-group/neural_renderer/search?q=AT_CHECK
(base) mona#mona:~/neural_renderer/neural_renderer/cuda$ vi create_texture_image_cuda.cpp
(base) mona#mona:~/neural_renderer/neural_renderer/cuda$ vi load_textures_cuda.cpp
(base) mona#mona:~/neural_renderer/neural_renderer/cuda$ vi rasterize_cuda.cpp
(base) mona#mona:~/neural_renderer$ pip install .
Processing /home/mona/neural_renderer
Building wheels for collected packages: neural-renderer-pytorch
Building wheel for neural-renderer-pytorch (setup.py) ... done
Created wheel for neural-renderer-pytorch: filename=neural_renderer_pytorch-1.1.3-cp37-cp37m-linux_x86_64.whl size=6215781 sha256=fbd9e8ef7340fa71b9fcd69da8ee06a1079ebbe5b4c2c3ce92e8124bc8cea7c5
Stored in directory: /tmp/pip-ephem-wheel-cache-tddilaof/wheels/c6/9b/9b/d2cda4f9ac2127278c21ea5c5e23c3354fe0e63365b7af7842
Successfully built neural-renderer-pytorch
Installing collected packages: neural-renderer-pytorch
Successfully installed neural-renderer-pytorch-1.1.3
(base) mona#mona:~/neural_renderer$ python examples/example1.py
Drawing: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 90/90 [00:04<00:00, 19.37it/s]
https://github.com/daniilidis-group/neural_renderer/issues/94
I have two python 3 locations. One is located here,
"C:\Users\Ryano\AppData\Local\Programs\Python\Python37-32"
The other is related to Anaconda3 here,
"C:\Users\Ryano\Anaconda3"
I want run a .py file that uses the numpy package in the command prompt using the Anaconda3 python version. I go to import numpy and it doesn't recognize it:
C:\Users\Ryano\Anaconda3>python
Python 3.7.1 (default, Oct 28 2018, 08:39:03) [MSC v.1912 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
import numpy
Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'numpy'
So I go to install the numpy package to the Anaconda 3 version python and this error pops up:
C:\Users\Ryano\Anaconda3\Scripts>pip install numpy
Collecting numpy
Using cached https://files.pythonhosted.org/packages/00/0e/5a8c34adb97fc1cd6636d78050e575945e874c8516d501421d5a0f377a6c/numpy-1.15.4-cp37-none-win_amd64.whl
Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'c:\users\ryano\anaconda3\lib\site-packages\html5lib-1.0.1.dist-info\METADATA'
Looking at the other posts similar to this one I could not find any solution that worked for my computer. Essentially I'm having issues with installing using pip.
Reinstall html5lib with conda:
conda install html5lib
There can be issues with using multiple installations on Windows.
Please check the answer to this question: what is the process of installing and working with PIL - Python Imaging Library ?
Hopefully one of the questions will fix the issue. If not, let me know.
With
"source activate graphlab"
in the terminal I can start up graphlab.
I've created it like this: "conda create -n graphlab python=2.7 anaconda", because using virtualenv with Anaconda is untested and not recommended (according to the warning in the terminal, I don't know whether this really is the case.).
After starting up graphlab the terminal shows:
discarding /Users/username/anaconda/bin from PATH
prepending /Users/username/anaconda/envs/graphlab/bin to PATH
But when I want to import graphlab in the Spider IDE it shows the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/username/anaconda/lib/python3.4/site packages/spyderlib/widgets/externalshell/sitecustomize.py", line 580, in runfile
execfile(filename, namespace)
File "/Users/username/anaconda/lib/python3.4/site-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 48, in execfile
exec(compile(open(filename, 'rb').read(), filename, 'exec'), namespace)
File "/Users/username/Documents/projectname/pythonfile.py", line 3, in <module>
import graphlab as gl
ImportError: No module named 'graphlab'
How can I solve this? I am totally new to installing these things, so hopefully someone can help me with an extensive step by step explanation.
The Dato Graphlab Create installer did not actually install graphlab on my Mac (El Capitan). I did the following (Anaconda is installed) in a terminal window:
% pip install graphlab-create
That subsequently installed Graphlab Create. You can then easily verify:
% python
Python 2.7.10 |Continuum Analytics, Inc.| (default, Sep 15 2015, 14:29:08)
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import graphlab
>>>
I've noticed that occasionally, Python will forget that Graphlab Create is installed. A repeat of the above 'pip' command will cause it to remember.
python anaconda graphlab
Open Anaconda command prompt. Run the following command:
pip install graphlab-create
The Spider IDE seems to be configured to use Python3.4 by default. That has to be changed to 2.7. This is from the error message on the issue.
There seems to be an issue with the Spider IDE.
Try importing from the command line interpreter (Anaconda version) and it should work fine.
Got the same error message, although I for sure had installed GraphLab on an environment with conda on Windows. I solved it with kernels for different environments.
Do the following on command line:
activate myenv
python -m ipykernel install --user --name myenv --display-name "Python (myenv)"
replace myenv in the code above with the name of the (conda-)environment in which graphlab is installed
Source (kernels for different environments): https://ipython.readthedocs.org/en/stable/install/kernel_install.html
Oh and to be sure that you actually had installed graphlab correct in your environment in the first place, you can test this by doing in command line:
Change environment:
activate nameofyourenvironment
Start Python:
python
Check in Python if GraphLab is found:
import graphlab
(if you don't get an error message, you did install graphlab correct in that particular environment)