I am trying to import shapely but getting error.
--------------------------------------------------------------------------- OSError Traceback (most recent call last) <ipython-input-9-62e74f53568a> in <module>
----> 1 import shapely.geometry
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/shapely/geometry/__init__.py in <module>
2 """
3
----> 4 from .base import CAP_STYLE, JOIN_STYLE
5 from .geo import box, shape, asShape, mapping
6 from .point import Point, asPoint
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/shapely/geometry/base.py in <module>
16
17 from shapely.affinity import affine_transform
---> 18 from shapely.coords import CoordinateSequence
19 from shapely.errors import WKBReadingError, WKTReadingError
20 from shapely.geos import WKBWriter, WKTWriter
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/shapely/coords.py in <module>
6 from ctypes import byref, c_double, c_uint
7
----> 8 from shapely.geos import lgeos
9 from shapely.topology import Validating
10
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/shapely/geos.py in <module>
136 _lgeos = load_dll('geos_c', fallbacks=alt_paths)
137
--> 138 free = load_dll('c').free
139 free.argtypes = [c_void_p]
140 free.restype = None
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/shapely/geos.py in load_dll(libname, fallbacks, mode)
60 raise OSError(
61 "Could not find lib {} or load any of its variants {}.".format(
---> 62 libname, fallbacks or []))
63
64 _lgeos = None
OSError: Could not find lib c or load any of its variants [].
I tried conda install -c conda-forge geos=3.7.1 but its not helping.
Can someone please help how can i repair Shapely. Shapely version I m using is 1.8.2.
I also tried conda install -c conda-forge geos=3.7.1 but it did not work.
I guess you are using an anaconda environment. So after you activate your environment in terminal;
conda activate <your_environment_name>
Using
pip install Shapely
in terminal, while my environment is active, I was able to use the package. Version is the 1.8.2, just like you wanted it.
For the possibility that you'd like to have a reminder on conda environments, here is a wonderful link.
Related
hi so I'm trying to import geopandas into my script
import pandas as pd
import geopandas as gpd
from shapely.geometry import Point
#handling txt
#remove 'lat=' and 'long=' then type change from object to float to make point.
df = pd.read_csv('latlong.txt', header=None, names = ['lat','long', 'name','description'])
df['lat'] = df['lat'].str.replace('lat=', '')
df['long'] = df['long'].str.replace('long=', '')
df['lat'] = df['lat'].astype(float)
df['long'] = df['long'].astype(float)
#make point geometry
df['geometry'] = df.apply(lambda row: Point(low['long'], low['lat']), axis=1) #long is X, lat is Y
#change df to gdf
gdf = gpd.GeoDataFrame(df, geometry = 'geometry', crs='EPSG:4326') #epsg4326 is WGS84
But when I try to run this in the jupyter notebook, using a conda environment from these steps: https://medium.com/#nrk25693/how-to-add-your-conda-environment-to-your-jupyter-notebook-in-just-4-steps-abeab8b8d084
I get the following error :
ImportError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_2312/3230284861.py in <module>
----> 1 import pandas as pd
2 import geopandas as gpd
3 from shapely.geometry import Point
4
5 #handling txt
~\.conda\envs\geojsongen\lib\site-packages\pandas\__init__.py in <module>
14
15 if missing_dependencies:
---> 16 raise ImportError(
17 "Unable to import required dependencies:\n" + "\n".join(missing_dependencies)
18 )
ImportError: Unable to import required dependencies:
numpy:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.9 from "C:\Users\User\.conda\envs\geojsongen\python.exe"
* The NumPy version is: "1.21.2"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: DLL load failed while importing _multiarray_umath: The specified module could not be found.
I installed the geopandas in this environment using the following command:
conda install -c conda-forge geopandas
Could someone advise me on how I can fix these errors? Any help is appreciated, thank you!!
edit:
I tried this pip install --upgrade --force-reinstall numpy, thanks #krmogi for this, but now I get this error, it looks like an issue with my geopandas installation? :
ImportError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_13932/3230284861.py in <module>
1 import pandas as pd
----> 2 import geopandas as gpd
3 from shapely.geometry import Point
4
5 #handling txt
~\.conda\envs\geojsongen\lib\site-packages\geopandas\__init__.py in <module>
----> 1 from geopandas._config import options # noqa
2
3 from geopandas.geoseries import GeoSeries # noqa
4 from geopandas.geodataframe import GeoDataFrame # noqa
5 from geopandas.array import points_from_xy # noqa
~\.conda\envs\geojsongen\lib\site-packages\geopandas\_config.py in <module>
107 use_pygeos = Option(
108 key="use_pygeos",
--> 109 default_value=_default_use_pygeos(),
110 doc=(
111 "Whether to use PyGEOS to speed up spatial operations. The default is True "
~\.conda\envs\geojsongen\lib\site-packages\geopandas\_config.py in _default_use_pygeos()
93
94 def _default_use_pygeos():
---> 95 import geopandas._compat as compat
96
97 return compat.USE_PYGEOS
~\.conda\envs\geojsongen\lib\site-packages\geopandas\_compat.py in <module>
7 import numpy as np
8 import pandas as pd
----> 9 import pyproj
10 import shapely
11 import shapely.geos
~\.conda\envs\geojsongen\lib\site-packages\pyproj\__init__.py in <module>
47 import warnings
48
---> 49 import pyproj.network
50 from pyproj._datadir import ( # noqa: F401 pylint: disable=unused-import
51 _pyproj_global_context_initialize,
~\.conda\envs\geojsongen\lib\site-packages\pyproj\network.py in <module>
8 import certifi
9
---> 10 from pyproj._network import ( # noqa: F401 pylint: disable=unused-import
11 _set_ca_bundle_path,
12 is_network_enabled,
ImportError: DLL load failed while importing _network: The specified module could not be found.
Your issue is happening here as shown in your traceback
----> 1 import pandas as pd
Make sure you have pandas installed.
pip install pandas
It also says that numpy C-extentions failed. Install numpy as well:
pip install numpy
While you're at it, make sure you have the other modules installed as well.
If you're still getting the same error, it's possible that setuptools is not properly installed. Do this:
pip uninstall -y numpy
pip uninstall -y setuptools
pip install setuptools
pip install numpy
If you still don't have any luck, try this:
pip install --upgrade --force-reinstall numpy
While importing ktrain, I am getting the following error:
AttributeError: module 'tensorflow_core.keras.activations' has no attribute 'swish'
Can anyone please help and tell how to get it going?
The same works fine on google colab.
Full Error:
AttributeError Traceback (most recent call last)
<ipython-input-3-d851226d5f91> in <module>
----> 1 import ktrain
2 from ktrain import text
~/opt/anaconda3/envs/Anmol/lib/python3.7/site-packages/ktrain/__init__.py in <module>
1 from .version import __version__
----> 2 from . import imports as I
3 from .core import ArrayLearner, GenLearner, get_predictor, load_predictor, release_gpu_memory
4 from .vision.learner import ImageClassLearner
5 from .text.learner import BERTTextClassLearner, TransformerTextClassLearner
~/opt/anaconda3/envs/Anmol/lib/python3.7/site-packages/ktrain/imports.py in <module>
227 logging.getLogger("transformers").setLevel(logging.ERROR)
228 try:
--> 229 import transformers
230 except ImportError:
231 warnings.warn("transformers not installed - needed by various models in 'text' module")
~/opt/anaconda3/envs/Anmol/lib/python3.7/site-packages/transformers/__init__.py in <module>
133
134 # Pipelines
--> 135 from .pipelines import (
136 Conversation,
137 ConversationalPipeline,
~/opt/anaconda3/envs/Anmol/lib/python3.7/site-packages/transformers/pipelines.py in <module>
46 import tensorflow as tf
47
---> 48 from .modeling_tf_auto import (
49 TF_MODEL_FOR_QUESTION_ANSWERING_MAPPING,
50 TF_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING,
~/opt/anaconda3/envs/Anmol/lib/python3.7/site-packages/transformers/modeling_tf_auto.py in <module>
49 from .configuration_utils import PretrainedConfig
50 from .file_utils import add_start_docstrings
---> 51 from .modeling_tf_albert import (
52 TFAlbertForMaskedLM,
53 TFAlbertForMultipleChoice,
~/opt/anaconda3/envs/Anmol/lib/python3.7/site-packages/transformers/modeling_tf_albert.py in <module>
22 import tensorflow as tf
23
---> 24 from .activations_tf import get_tf_activation
25 from .configuration_albert import AlbertConfig
26 from .file_utils import (
~/opt/anaconda3/envs/Anmol/lib/python3.7/site-packages/transformers/activations_tf.py in <module>
52 "gelu": tf.keras.layers.Activation(gelu),
53 "relu": tf.keras.activations.relu,
---> 54 "swish": tf.keras.activations.swish,
55 "silu": tf.keras.activations.swish,
56 "gelu_new": tf.keras.layers.Activation(gelu_new),
AttributeError: module 'tensorflow_core.keras.activations' has no attribute 'swish' ```
Okay so there is some issue with Macs with M1.
Followed the following to resolve the issue:
(https://github.com/apple/tensorflow_macos/issues/48)
Anaconda start a new environment Uninstall tensorflow & tensorboard
if exists
Rename all the files inside the x86_64 folder from 11_0 to 10_16.
Example: tensorflow_macos-0.1a0-cp38-cp38-macosx_10_16_x86_64.whl
In Conda console run below with 'username' replaced with your username:
pip install pip wheel setuptools cached-property six
pip install
"/Users/username/Downloads/tensorflow_macos/x86_64/grpcio-1.33.2-cp38-cp38-macosx_10_16_x86_64.whl"
pip install
"/Users/username/Downloads/tensorflow_macos/x86_64/h5py-2.10.0-cp38-cp38-macosx_10_16_x86_64.whl"
pip install
"/Users/username/Downloads/tensorflow_macos/x86_64/numpy-1.18.5-cp38-cp38-macosx_10_16_x86_64.whl"
pip install
"/Users/username/Downloads/tensorflow_macos/x86_64/scipy-1.5.4-cp38-cp38-macosx_10_16_x86_64.whl"
pip install
"/Users/username/Downloads/tensorflow_macos/x86_64/tensorflow_addons-0.11.2+mlcompute-cp38-cp38-macosx_10_16_x86_64.whl"
pip install absl-py astunparse flatbuffers gast google_pasta
keras_preprocessing opt_einsum protobuf tensorflow_estimator
termcolor typing_extensions wrapt wheel tensorboard typeguard
pip install
"/Users/username/Downloads/tensorflow_macos/x86_64/tensorflow_macos-0.1a0-cp38-cp38-macosx_10_16_x86_64.whl"
Check the versions that you are using for Tensorflow (and transformers). You can check this issue in GitHub:
https://github.com/amaiya/ktrain/issues/255
I use ktrain==0.25.4 and tensorflow==2.4.1 and everything worked.
I am having some trouble trying to import geopandas in my Mac. I installed it by the conda command:
conda install -c conda-forge geopandas
After I try to import by I get the following error:
ImportError Traceback (most recent call last)
<ipython-input-2-e508418be6dd> in <module>()
1 import pandas as pd
----> 2 import geopandas as gpd
3 get_ipython().magic('matplotlib inline')
/anaconda/lib/python3.6/site-packages/geopandas/__init__.py in <module>()
2 from geopandas.geodataframe import GeoDataFrame
3
----> 4 from geopandas.io.file import read_file
5 from geopandas.io.sql import read_postgis
6 from geopandas.tools import sjoin
/anaconda/lib/python3.6/site-packages/geopandas/io/file.py in <module>()
1 import os
2
----> 3 import fiona
4 import numpy as np
5
/anaconda/lib/python3.6/site-packages/fiona/__init__.py in <module>()
67 from six import string_types
68
---> 69 from fiona.collection import Collection, BytesCollection, vsi_path
70 from fiona._drivers import driver_count, GDALEnv
71 from fiona.drvsupport import supported_drivers
/anaconda/lib/python3.6/site-packages/fiona/collection.py in <module>()
7
8 from fiona import compat
----> 9 from fiona.ogrext import Iterator, ItemsIterator, KeysIterator
10 from fiona.ogrext import Session, WritingSession
11 from fiona.ogrext import (
ImportError: dlopen(/anaconda/lib/python3.6/site-packages/fiona/ogrext.cpython-36m-darwin.so, 2): Library not loaded: #rpath/libxerces-c-3.1.dylib
Referenced from: /anaconda/lib/libgdal.20.dylib
Reason: image not found
I tried updating my anaconda by running:
conda update conda
Got the same error, so I tried uninstalling with conda and installing with pip. Got the same error.
Then I tried to forge fiona with conda,then installing with pip but it got me nowhere, and now I'm stuck. Any ideas?
I think could have been a problem with the conda-forge feedstock for fiona:
https://github.com/conda-forge/fiona-feedstock/issues/62
I had the same problem a few days ago but it seems to have been resolved now. Have you tried again?
I installed moviepy package using pip. Whenever I import moviepy, the following error appears:
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-1-3137d113b348> in <module>()
6 import os
7 import math
----> 8 from moviepy.editor import VideoFileClip
9 from IPython.display import HTML
10 get_ipython().magic('matplotlib inline')
C:\Users\manch_000\Anaconda3\lib\site-packages\moviepy\editor.py in <module>()
20 # Clips
21
---> 22 from .video.io.VideoFileClip import VideoFileClip
23 from .video.io.ImageSequenceClip import ImageSequenceClip
24 from .video.VideoClip import VideoClip, ImageClip, ColorClip, TextClip
C:\Users\manch_000\Anaconda3\lib\site-packages\moviepy\video\io\VideoFileClip.py in <module>()
1 import os
2
----> 3 from moviepy.video.VideoClip import VideoClip
4 from moviepy.audio.io.AudioFileClip import AudioFileClip
5 from moviepy.Clip import Clip
C:\Users\manch_000\Anaconda3\lib\site-packages\moviepy\video\VideoClip.py in <module>()
19
20 import moviepy.audio.io as aio
---> 21 from .io.ffmpeg_writer import ffmpeg_write_image, ffmpeg_write_video
22 from .io.ffmpeg_reader import ffmpeg_read_image
23 from .io.ffmpeg_tools import ffmpeg_merge_video_audio
C:\Users\manch_000\Anaconda3\lib\site-packages\moviepy\video\io\ffmpeg_writer.py in <module>()
17 from tqdm import tqdm
18
---> 19 from moviepy.conf import FFMPEG_BINARY
20 from moviepy.tools import verbose_print
21
C:\Users\manch_000\Anaconda3\lib\site-packages\moviepy\conf.py in <module>()
59 FFMPEG_BINARY = 'ffmpeg.exe'
60 else:
---> 61 raise IOError("FFMPEG binary not found. Try installing MoviePy"
62 " manually and specify the path to the binary in"
63 " the file conf.py")
OSError: FFMPEG binary not found. Try installing MoviePy manually and specify the path to the binary in the file conf.py
I downloaded the FFMPEG file but I don't know to specify the path in conf.py.
Any help ?
I encountered this issue when trying to use PythonVideoConverter
The steps I took to finally resolve this were:
pip install ffmpeg
Then you have to go download the ffmpeg executables separately. Source code can be found here:
http://ffmpeg.org/
I actually used the pre-built binaries for windows available here:
https://github.com/BtbN/FFmpeg-Builds/releases
The lines to use PythonVideoConverter are:
from converter import Converter
conv = Converter()
Add the absolute path to the executables as input parameters to Converter(), ie:
ffmpegPath = r"c:\...\ffmpeg.exe"
ffprobePath = r"c:\...\ffprobe.exe"
from converter import Converter
conv = Converter(ffmpegPath, ffprobePath)
edit: This was on Windows 10 using Python 3.7.4. I used the win64-gpl build of ffmpeg.
I had this same problem, but in ubuntu. It got solved by simply installing ffmpeg using apt-get:
sudo apt-get install ffmpeg
I don't have anaconda , but as per error dump
C:\Users\manch_000\Anaconda3\lib\site-packages\moviepy\conf.py in <module>()
59 FFMPEG_BINARY = 'ffmpeg.exe'
60 else:
---> 61 raise IOError("FFMPEG binary not found. Try installing
Here are steps that I can think of,
Find out absolute path for ffmpeg.exe on your system.
Copy that path.
Edit C:\Users\manch_000\Anaconda3\lib\site-packages\moviepy\conf.py
change line 59 to
FFMPEG_BINARY = 'c:\your_path_to_ffmpeg.exeutable\ffmpeg.exe'
save the conf.py
Hope this helps.
I am running python on Anaconda. I downloaded the Theano from "https://github.com/Theano/Theano.git" and installed it by running
cd Theano
python setup.py develop
However, when I tried to import the theano on Ipython notebook. I got the ""dot.exe" not found in path." exception. Have no clue what is going on...
import numpy as np
import time
import theano
Exception Traceback (most recent call last)
<ipython-input-1-432f5c01387b> in <module>()
1 import numpy as np
2 import time
----> 3 import theano
c:\users\t-ninma\documents\studymaterials\theano\theano\__init__.py in <module>()
79 from theano.misc.safe_asarray import _asarray
80
---> 81 from theano.printing import pprint, pp
82
83 from theano.scan_module import scan, map, reduce, foldl, foldr, clone
c:\users\t-ninma\documents\studymaterials\theano\theano\printing.py in <module>()
42 pydot_imported_msg = "pydot can't find graphviz"
43 else:
---> 44 pd.Dot.create(pd.Dot())
45 pydot_imported = True
46 except ImportError:
C:\Users\t-ninma\AppData\Local\Continuum\Anaconda2\lib\site-packages\pydot.pyc in create(self, prog, format)
1874 raise Exception(
1875 '"{prog}" not found in path.'.format(
-> 1876 prog=prog))
1877 else:
1878 raise
Exception: "dot.exe" not found in path.
Seems like you are running anaconda in windows. When installing Theano in a windows machines sometimes there are some issues.
Here you can see a good way to install theano in windows machines. If you have installed any mingw compiler or msys before, remove then before following this method.
Hope this method will work..!