In have this behavior that I cannot really understand. Some background might be in place. I earlier created an environment called geo in which I installed geopandas. I worked like a charm, but I later realized that I wanted to split POLYGON-type objects into smaller ones.
Reading a little, I found out that QGIS has something that might help. So, following this really helpful answer (https://stackoverflow.com/a/67447061/5363686), I created a conda-qgis environment to be able to
from qgis.core import *
and it worked like a charm. I also install geopandas in that environment, as can be seen below it is there:
# packages in environment at C:\Users\s-degossondevarennes\Anaconda3\envs\conda-qgis:
#
# Name Version Build Channel
attrs 21.2.0 pyhd8ed1ab_0 conda-forge
boost-cpp 1.74.0 h54f0996_3 conda-forge
brotlipy 0.7.0 py39hb82d6ee_1001 conda-forge
bzip2 1.0.8 h8ffe710_4 conda-forge
ca-certificates 2021.5.30 h5b45459_0 conda-forge
cairo 1.16.0 hb19e0ff_1008 conda-forge
certifi 2021.5.30 py39hcbf5309_0 conda-forge
cffi 1.14.5 py39h0878f49_0 conda-forge
cfitsio 3.470 h0af3d06_7 conda-forge
chardet 4.0.0 py39hcbf5309_1 conda-forge
click 7.1.2 pyh9f0ad1d_0 conda-forge
click-plugins 1.1.1 py_0 conda-forge
cligj 0.7.2 pyhd8ed1ab_0 conda-forge
coverage 5.5 py39hb82d6ee_0 conda-forge
cryptography 3.4.7 py39hd8d06c1_0 conda-forge
curl 7.77.0 h789b8ee_0 conda-forge
cycler 0.10.0 py_2 conda-forge
decorator 5.0.9 pyhd8ed1ab_0 conda-forge
exiv2 0.27.1 hfa2c1cf_0 conda-forge
expat 2.4.1 h39d44d4_0 conda-forge
fiona 1.8.20 py39h9f1b043_0 conda-forge
fontconfig 2.13.1 h1989441_1005 conda-forge
freetype 2.10.4 h546665d_1 conda-forge
freexl 1.0.6 ha8e266a_0 conda-forge
future 0.18.2 py39hcbf5309_3 conda-forge
gdal 3.2.2 py39h6795fcd_5 conda-forge
geopandas 0.9.0 pyhd8ed1ab_1 conda-forge
geopandas-base 0.9.0 pyhd8ed1ab_1 conda-forge
geos 3.9.1 h39d44d4_2 conda-forge
geotiff 1.6.0 h8e90983_5 conda-forge
gettext 0.19.8.1 h1a89ca6_1005 conda-forge
BUT, I cannot import it
from flatten_json import flatten
import requests
import flatten_json
import pandas as pd
import os, json
import numpy as np
import glob
import pathlib
import matplotlib.pyplot as plt
import geopandas
from qgis.core import *
#import qgis-plutil
from pandas.io.json import json_normalize
from operator import attrgetter
from shapely.geometry import Point, Polygon
import geopandas as gpd
from fetch_api_data import get_floor_boundary_data, get_obstacle_data,get_xy_data, jsonNormalize
from store_function import flatten_nested_json_df, get_items
np.seterr(divide='ignore', invalid='ignore')
pd.set_option('display.max_columns', None)
from IPython.display import Markdown as md
from shapely.geometry import box, Polygon, MultiPolygon, GeometryCollection
returns:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-5cd75bf81655> in <module>
8 import pathlib
9 import matplotlib.pyplot as plt
---> 10 import geopandas
11 from qgis.core import *
12 #import qgis-plutil
ModuleNotFoundError: No module named 'geopandas'
This, is rather strange. And yes, I open my notebook in the right environement.
Does anyone spot my mistake?
Thankful for any help!
Related
Importing the numpy c-extensions failed
I am trying to use numpy in terminal, when i imported it it returned an error.But whe I import numpy in pytharm Python Console,it worked well.I have python 2.7.10 and 3.7.5,python 3.7.5 was used in pytharm. I uninstalled numpy on all versions of python and reinstalled it on python 3.7.5 only, but it returned the same error. I reinstall packages via the command line by entering:
python3 -m pip install --user numpy scipy matplotlib ipython jupyter pandas sympy nose
but it returned the same error too.I guess it's a multi-environment problem.
Tried uninstall and install numpy and setuptools like this:
pip uninstall -y numpy
pip uninstall -y setuptools
pip install setuptools
pip install numpy
but it returned the same error too.
My python3 pip list:
absl-py 0.9.0
aiodns 2.0.0
aiohttp 3.5.4
appnope 0.1.0
astor 0.8.1
async-timeout 3.0.1
attrs 19.1.0
backcall 0.1.0
beautifulsoup4 4.5.3
bleach 3.1.0
browsermob-proxy 0.8.0
bs4 0.0.1
cchardet 2.1.4
certifi 2019.3.9
cffi 1.12.3
chardet 3.0.4
cssselect 1.0.3
cycler 0.10.0
decorator 4.4.1
defusedxml 0.6.0
entrypoints 0.3
fake-useragent 0.1.11
gast 0.3.2
google-pasta 0.1.8
grpcio 1.26.0
h5py 2.10.0
idna 2.6
importlib-metadata 1.3.0
ipykernel 5.1.3
ipython 5.4.1
ipython-genutils 0.2.0
ipywidgets 7.5.1
jedi 0.15.2
Jinja2 2.10.3
joblib 0.14.1
jsonschema 3.2.0
jupyter 1.0.0
jupyter-client 5.3.4
jupyter-console 5.2.0
jupyter-core 4.6.1
Keras 2.2.4
Keras-Applications 1.0.8
Keras-Preprocessing 1.1.0
kiwisolver 1.1.0
lxml 4.3.3
Markdown 3.1.1
MarkupSafe 1.1.1
matplotlib 3.1.2
mistune 0.8.4
more-itertools 8.0.2
mpmath 1.1.0
multidict 4.5.2
nbconvert 5.6.1
nbformat 4.4.0
nose 1.3.7
notebook 6.0.2
ntplib 0.3.3
numpy 1.17.4
opencv-python 4.1.2.30
pandas 0.25.3
pandocfilters 1.4.2
parso 0.5.2
pexpect 4.7.0
pickleshare 0.7.5
Pillow 6.2.1
pip 19.3.1
prometheus-client 0.7.1
prompt-toolkit 1.0.18
protobuf 3.11.2
ptyprocess 0.6.0
pycares 3.0.0
pycparser 2.19
pycrypto 2.6.1
Pygments 2.5.2
PyMySQL 0.9.3
pyparsing 2.4.5
pyquery 1.4.0
pyrsistent 0.15.6
python-dateutil 2.8.1
pytz 2019.3
PyYAML 5.2
pyzmq 18.1.1
qtconsole 4.6.0
redis 3.3.11
requests 2.18.4
scikit-learn 0.22
scipy 1.4.1
selenium 3.11.0
Send2Trash 1.5.0
setuptools 42.0.2
simplegeneric 0.8.1
six 1.13.0
sklearn 0.0
soupsieve 1.9.1
splinter 0.13.0
sympy 1.5
tensorboard 1.14.0
tensorflow 1.14.0
tensorflow-estimator 1.14.0
termcolor 1.1.0
terminado 0.8.3
testpath 0.4.4
tornado 6.0.3
traitlets 4.3.3
urllib3 1.22
wcwidth 0.1.7
webencodings 0.5.1
Werkzeug 0.16.0
wheel 0.33.6
widgetsnbextension 3.5.1
wrapcache 1.0.8
wrapt 1.11.1
xvfbwrapper 0.2.9
yarl 1.3.0
zipp 0.6.0
How can I solve this problem?
Reproducing code example:
import numpy
Error message:
Blockquote
Python 3.7.5 (default, Nov 1 2019, 02:16:32) [Clang 11.0.0
(clang-1100.0.33.8)] on darwin Type "help", "copyright", "credits" or
"license" for more information.
import numpy Traceback (most recent call last): File "/Users/chuck/Library/Python/3.7/lib/python/site-packages/numpy/core/init.py",
line 17, in
from . import multiarray File "/Users/chuck/Library/Python/3.7/lib/python/site-packages/numpy/core/multiarray.py",
line 14, in
from . import overrides File "/Users/chuck/Library/Python/3.7/lib/python/site-packages/numpy/core/overrides.py",
line 7, in
from numpy.core._multiarray_umath import ( ImportError: dlopen(/Users/chuck/Library/Python/3.7/lib/python/site-packages/numpy/core/_multiarray_umath.cpython-37m-darwin.so,
2): Symbol not found: ___addtf3 Referenced from:
/Users/chuck/Library/Python/3.7/lib/python/site-packages/numpy/core/../.dylibs/libquadmath.0.dylib Expected in: /usr/lib/libSystem.B.dylib in
/Users/chuck/Library/Python/3.7/lib/python/site-packages/numpy/core/../.dylibs/libquadmath.0.dylib
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "", line 1, in
File
"/Users/chuck/Library/Python/3.7/lib/python/site-packages/numpy/init.py",
line 142, in
from . import core File "/Users/chuck/Library/Python/3.7/lib/python/site-packages/numpy/core/init.py",
line 47, in
raise ImportError(msg) ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy c-extensions failed.
- Try uninstalling and reinstalling numpy.
- If you have already done that, then:
1. Check that you expected to use Python3.7 from "/usr/local/opt/python/bin/python3.7",
and that you have no directories in your PATH or PYTHONPATH that can
interfere with the Python and numpy version "1.17.4" you're trying to use.
2. If (1) looks fine, you can open a new issue at
https://github.com/numpy/numpy/issues. Please include details on:
- how you installed Python
- how you installed numpy
- your operating system
- whether or not you have multiple versions of Python installed
- if you built from source, your compiler versions and ideally a build log
If you're working with a numpy git repository, try git clean -xdf (removes all files not under version control) and rebuild numpy.
Note: this error has many possible causes, so please don't comment on
an existing issue about this - open a new one instead.
Original error was:
dlopen(/Users/chuck/Library/Python/3.7/lib/python/site-packages/numpy/core/_multiarray_umath.cpython-37m-darwin.so,
2): Symbol not found: ___addtf3 Referenced from:
/Users/chuck/Library/Python/3.7/lib/python/site-packages/numpy/core/../.dylibs/libquadmath.0.dylib Expected in: /usr/lib/libSystem.B.dylib in
/Users/chuck/Library/Python/3.7/lib/python/site-packages/numpy/core/../.dylibs/libquadmath.0.dylib
I solved this issue like this:
bogon:bin chuck$ brew unlink python3
Unlinking /usr/local/Cellar/python/3.7.5... 0 symlinks removed
bogon:bin chuck$ brew link python3
Linking /usr/local/Cellar/python/3.7.5...
Error: Could not symlink bin/easy_install-3.7
Target /usr/local/bin/easy_install-3.7
already exists. You may want to remove it:
rm '/usr/local/bin/easy_install-3.7'
To force the link and overwrite all conflicting files:
brew link --overwrite python
To list all files that would be deleted:
brew link --overwrite --dry-run python
bogon:bin chuck$ brew link --overwrite python3
Linking /usr/local/Cellar/python/3.7.5... 24 symlinks created
This question already has answers here:
ImportError: cannot import name '_obtain_input_shape' from keras
(7 answers)
Closed 4 years ago.
When I run
from keras_vggface.vggface import VGGFace
# Based on VGG16 architecture -> old paper(2015)
vggface = VGGFace(model='vgg16') # or VGGFace() as default
# Based on RESNET50 architecture -> new paper(2017)
vggface = VGGFace(model='resnet50')
# Based on SENET50 architecture -> new paper(2017)
vggface = VGGFace(model='senet50')
in instructions.
I got this error
ImportError: cannot import name '_obtain_input_shape'
I follow the instructions in install the keras_vggface. And here is a list info of my packages.
# packages in environment at /Users/lzq/anaconda3/envs/py36_faceRec:
#
# Name Version Build Channel
bleach 1.5.0 <pip>
ca-certificates 2018.03.07 0
certifi 2018.10.15 py36_0
enum34 1.1.6 <pip>
h5py 2.8.0 <pip>
html5lib 0.9999999 <pip>
Keras 2.1.1 <pip>
keras-vggface 0.5 <pip>
libcxx 4.0.1 hcfea43d_1
libcxxabi 4.0.1 hcfea43d_1
libedit 3.1.20170329 hb402a30_2
libffi 3.2.1 h475c297_4
Markdown 3.0.1 <pip>
ncurses 6.1 h0a44026_0
numpy 1.15.4 <pip>
openssl 1.1.1 h1de35cc_0
Pillow 5.3.0 <pip>
pip 18.1 py36_0
protobuf 3.6.1 <pip>
python 3.6.7 haf84260_0
PyYAML 3.13 <pip>
readline 7.0 h1de35cc_5
scipy 1.1.0 <pip>
setuptools 40.5.0 py36_0
six 1.11.0 <pip>
sqlite 3.25.2 ha441bb4_0
tensorflow 1.4.0 <pip>
tensorflow-tensorboard 0.4.0 <pip>
tk 8.6.8 ha441bb4_0
Werkzeug 0.14.1 <pip>
wheel 0.32.2 py36_0
xz 5.2.4 h1de35cc_4
zlib 1.2.11 hf3cbc9b_2
The VGGFace package you're using is configured for an older version of Keras. The easiest solution for you is to edit the keras-vggface/keras_vggface/models.py file inside the vvgface directory and change line 15 from:
from keras.applications.imagenet_utils import _obtain_input_shape
to
from keras_applications.imagenet_utils import _obtain_input_shape
Alternatively you can also just downgrade Keras to 2.2.0 if you find that easier
Solution: was using jupyter notebook on windows, so never able to connect to the env/kernel. Loaded up the anaconda environment in pycharm and everything works now
I'm using Anaconda and the jupyter notebook but I'm constantly getting an error trying to import pandas datareader and keep getting the ModuleNotFoundError for some reason.
I tried to reinstall pandas-datareader several times with several install methods (regular, via site link, pip install) while being in the active environment.
I tried downgrading my Python version down to 3.6.0 but getting the same error for all of them.
I also checked the folder in the environment at /Lib/site-packages and both folders (pandas_datareader and pandas_datareader-0.5.0.dist-info) are located there.
Don't really know where to go from here. Any help is appreciated
import datetime as dt
import matplotlib.pyplot as plt
from matplotlib import style
import pandas as pd
import pandas_datareader.data as web
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-1fbb66132a8a> in <module>()
3 from matplotlib import style
4 import pandas as pd
----> 5 import pandas_datareader.data as web
ModuleNotFoundError: No module named 'pandas_datareader'
# packages in environment at C:\Users\....\Anaconda3\envs\finance:
#
asn1crypto 0.24.0 py36_0
beautifulsoup4 4.6.0 py36hd4cc5e8_1
ca-certificates 2017.08.26 h94faf87_0 anaconda
certifi 2017.11.5 py36hb8ac631_0 anaconda
cffi 1.11.4 py36hfa6e2cd_0
chardet 3.0.4 py36h420ce6e_1
cryptography 2.1.4 py36he1d7878_0
cycler 0.10.0 py36h009560c_0
freetype 2.8 vc14h17c9bdf_0 [vc14] anaconda
icc_rt 2017.0.4 h97af966_0
icu 58.2 vc14hc45fdbb_0 [vc14] anaconda
idna 2.6 py36h148d497_1
intel-openmp 2018.0.0 hd92c6cd_8
jpeg 9b vc14h4d7706e_1 [vc14] anaconda
libpng 1.6.32 vc14h5163883_3 [vc14] anaconda
matplotlib 2.1.1 py36h2062329_0
mkl 2018.0.1 h2108138_4
numpy 1.14.0 py36h4a99626_0
openssl 1.0.2n h74b6da3_0 anaconda
pandas 0.22.0 py36h6538335_0
pandas-datareader 0.5.0 py36_0 anaconda
pip 9.0.1 py36h226ae91_4
pycparser 2.18 py36hd053e01_1
pyopenssl 17.5.0 py36h5b7d817_0
pyparsing 2.2.0 py36h785a196_1
pyqt 5.6.0 py36hb5ed885_5
pysocks 1.6.7 py36h698d350_1
python 3.6.4 h6538335_1
python-dateutil 2.6.1 py36h509ddcb_1
pytz 2017.3 py36h1d3fa6b_0
qt 5.6.2 vc14h6f8c307_12 [vc14] anaconda
requests 2.18.4 py36h4371aae_1
requests-file 1.4.1 py36_0
requests-ftp 0.3.1 py36_0
scikit-learn 0.19.1 py36h53aea1b_0
scipy 1.0.0 py36h1260518_0
setuptools 38.4.0 py36_0
sip 4.18.1 py36h9c25514_2
six 1.11.0 py36h4db2310_1
sqlite 3.20.1 vc14h7ce8c62_1 [vc14] anaconda
tornado 4.5.3 py36_0
urllib3 1.22 py36h276f60a_0
vc 14 h0510ff6_3
vs2015_runtime 14.0.25123 3
wheel 0.30.0 py36h6c3ec14_1
win_inet_pton 1.0.1 py36he67d7fd_1
wincertstore 0.2 py36h7fe50ca_0
zlib 1.2.11 vc14h1cdd9ab_1 [vc14] anaconda
I am guessing that /Lib/site-packages is not in your PYTHONPATH. See:
https://leemendelowitz.github.io/blog/how-does-python-find-packages.html
"sys.path is populated using the current working directory, followed by directories listed in your PYTHONPATH environment variable, followed by installation-dependent default paths, which are controlled by the site module."
TLDR: Make sure that /Lib/site-packages/ is in your PYTHONPATH.
anaconda3 was installed on linux.
Several modules were installed with conda. They are visible:
(cytogen) jeanpat#10TS-Notebook:~$ conda list
# packages in environment at /home/jeanpat/anaconda3/envs/cytogen:
#
boost 1.64.0 py36_4 conda-forge
boost-cpp 1.64.0 1 conda-forge
bzip2 1.0.6 1 conda-forge
ca-certificates 2017.08.26 h1d4fec5_0
...
graph-tool 2.25 py36hbffa022_0 ostrokach-forge
hdf5 1.8.17 2
mahotas 1.4.4 py36_0 conda-forge
mkl 2018.0.0 hb491cac_4
mpfr 3.1.5 0 conda-forge
ncurses 6.0 h9df7e31_2
numpy 1.12.1 py36he24570b_1
opencv 3.1.0 np112py36_1
opencv3 3.1.0 py36_0 menpo
openssl 1.0.2m h8cfc7e7_0
pandas 0.21.0 py36_0 conda-forge
pillow 3.4.2 py36_0
pip 9.0.1 py36h6c6f9ce_4
...
pytorch 0.2.0 py36hf0d2509_4cu75 soumith
pytz 2017.3 py_2 conda-forge
readline 7.0 ha6073c6_4
scipy 1.0.0 py36hbf646e7_0
setuptools 36.5.0 py36he42e2e1_0
six 1.11.0 py36_1 conda-forge
sparsehash 2.0.3 0 conda-forge
sqlite 3.20.1 hb898158_2
tk 8.6.7 hc745277_3
torchvision 0.1.9 py36h7584368_1 soumith
wheel 0.29.0 py36he7f4e38_1
xz 5.2.3 h55aa19d_2
zlib 1.2.11 ha838bed_2
When ipython is launched, some modules can't be imported (cv2, mahotas ...):
~$ ipython
Python 3.6.3 |Anaconda, Inc.| (default, Oct 13 2017, 12:02:49)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.1.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import mahotas
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-adadab8066d2> in <module>()
----> 1 import mahotas
ModuleNotFoundError: No module named 'mahotas'
In [2]: import cv2
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-72fbbcfe2587> in <module>()
----> 1 import cv2
ModuleNotFoundError: No module named 'cv2'
I guess it is a path issue, for example importing numpy works:
In [3]: import numpy
In [4]: numpy.__version__
Out[4]: '1.13.3'
but the version doesn't match the numpy version from the virtualenv .
I am trying to install & use Pandas-Datareader, but when after I have installed it, I receive a ModuleNotFoundError when I try and import it.
I am using Jupyter Notebook installed using Anaconda - so use the conda installer to install new packages.
After typing source activate ipykernel_py3 to activate the Python3 kernel environment, I have used conda install -c anaconda pandas-datareader=0.4.0 to install Pandas-Datareader.
If I try conda list, then I get the output below - which shows Pandas_Datareader installed.
But if I try the command ```import pandas_datareader as pdr`` (as found in documentation here), then I get an error message
ModuleNotFoundError: No module named 'pandas_datareader'
(This happens in both the Jupyter notebook and in the Python3 interpreter running in this environment.
Can anybody help?
Many thanks
** Conda List output:**
# packages in environment at /Users/Chris/anaconda3/envs/ipykernel_py3:
#
appnope 0.1.0 py36_0
beautifulsoup4 4.5.3 py36_0
cycler 0.10.0 py36_0
decorator 4.0.11 py36_0
freetype 2.5.5 2
icu 54.1 0
ipykernel 4.6.1 py36_0
ipython 6.0.0 py36_0
ipython_genutils 0.2.0 py36_0
jupyter_client 5.0.1 py36_0
jupyter_core 4.3.0 py36_0
libpng 1.6.27 0
matplotlib 2.0.2 np112py36_0
mkl 2017.0.1 0
numpy 1.12.1 py36_0
openssl 1.0.2k 1
pandas 0.20.1 np112py36_0
pandas-datareader 0.4.0 py36_0 anaconda
path.py 10.3.1 py36_0
pexpect 4.2.1 py36_0
pickleshare 0.7.4 py36_0
pip 9.0.1 py36_1
prompt_toolkit 1.0.14 py36_0
ptyprocess 0.5.1 py36_0
pygments 2.2.0 py36_0
pyparsing 2.1.4 py36_0
pyqt 5.6.0 py36_2
python 3.6.1 0
python-dateutil 2.6.0 py36_0
pytz 2017.2 py36_0
pyzmq 16.0.2 py36_0
qt 5.6.2 2
readline 6.2 2
requests 2.14.2 py36_0 anaconda
requests-file 1.4.1 py36_0 anaconda
requests-ftp 0.3.1 py36_0 anaconda
scipy 0.19.0 np112py36_0
seaborn 0.7.1 py36_0
setuptools 27.2.0 py36_0
simplegeneric 0.8.1 py36_1
sip 4.18 py36_0
six 1.10.0 py36_0
sqlite 3.13.0 0
tk 8.5.18 0
tornado 4.5.1 py36_0
traitlets 4.3.2 py36_0
wcwidth 0.1.7 py36_0
wheel 0.29.0 py36_0
xz 5.2.2 1
zlib 1.2.8 3
Are you running the notebook in the ipykernel_py3 environment?
source activate ipykernel_py3
ipython notebook
Just type
pip install pandas_datareader in your anaconda prompt
and try running it again in jupyter.