Module not found when running geopandas identity - geopandas

I'm attempting to conduct a vector identity using two shapefiles in geopandas. When this is run I get the following error.
ModuleNotFoundError: No module named 'geopandas.sindex'
I've done a quick search and there is no module called geopandas.sindex related to vector identity or anything like it. My geopandas is installed under anaconda and it is installed as I am able to import geopandas.
Here is an excerpt from my code.
import geopandas as gpd
geo_df1 = gpd.read_file("shapefile1.shp")
geo_df2 = gpd.read_file("shapefile2.shp")
geo_df3 = gpd.overlay(geo_df1,geo_df2,how="identity")`
I strongly suspect something has gone wrong in my installation as this operation was done correctly historically so any recommendations towards fixing the installation is appreciated. The expected result will be being able to run the geopandas operation successfully.

Related

deleting stopwords with Gensim

I'm trying to learn Gensim using its site.
There is a function named 'remove_stopword_tokens' which is useful for my research.
Now, although the module is defined and is present on their website (exact link: link),I can't import it on my colab
Note: This is my code:
import gensim
from gensim.parsing.preprocessing import remove_stopword_tokens
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-2-dbd838c83237> in <module>
----> 1 from gensim.parsing.preprocessing import remove_stopword_tokens
ImportError: cannot import name 'remove_stopword_tokens' from 'gensim.parsing.preprocessing' (/usr/local/lib/python3.7/dist-packages/gensim/parsing/preprocessing.py)
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
updated & corrected answer
You've run into a limitation of Google Colab - it may not have the most-recent version of libraries.
You can see this by checking what the value of gensim.__version__ is. In my check of Google Colab right now (September 2022), it reports 3.6.0 – a version of Gensim that's about 4 years old, and lacks later fixes & addtions. The remove_stopwords_tokens() function was only added recently.
Fortunately, you can update the gensim package backing the Colab notebook yourself, using a shell-escape to run pip. Inside a Colab cell, run:
!pip install gensim -U
If you'd already done an import gensim, it will warn you that you must restart the runtime for the new code to be found.
Note that for clarity reasons you might choose to prefer using more-specific imports, as many project style guides suggest, rather than doing any broad top-level import gensim at all. Just mport the individual classes and/or functions you need, specifically & explicitly. That is, just:
from gensim.parsing.preprocessing import remove_stopword_tokens
# ... other exact class/function/variable imports you'll use...
remove_stopword_tokens(sentence)
On the other hand, if you want things simple-but-sloppy (not recommended), once you import gensim, it has already (via its own custom initialization routines) imported all of its submodules for you. So you could do:
import gensim # parsing & all gensim's other submodules now referenceable!
gensim.parsing.remove_stopword_tokens(sentence)
(Pro Python programmer style tends not to do this latter approach, of prefixing all in-the-actual-code calls with long dot-paths.)

Couldn't import package when I download it using pip download <name_of_package> ? It went to Lib and I am unable to import it

I am just learning coding
I wanted to download a package from pypi.org using the pip function . but after I downloaded it , I wasn't able to import the openpyxl package . I checked where the openpyxl file was that I had downloaded and found the it was in lib\site-packages directory instead of being in a sit-packages which is a different directory.
*In the picture if have taken pictures of all the visible information that I could find out about this problem and put it one picture, I hope you can understand what my question is by the image .
*Also should i be worried about the red color text that is showing in my terminal .
please if you can help , that would be great , I use windows 10 with python 3.10.
I have taken multiple pictures of messages that I could see then put them all in one picture using photoshop , that is why the picture might look inaccurate , I just wanted all the information to be in one picture , hope you can understand my question, and i would be great full if you could help .
You have installed openpyxl to your global python, but your project in python is using a virtual environment that has its own set of packages. To install into the environment used by your project go (in Pycharm) to File -> Settings -> Project -> Python Interpreter, then hit the small plus button, search for openpyxl and hit Install Package

geopandas readfile not recognizing a legit shape file

I am trying to read to geopandas what looks like a legitimate shapefile:
gpd.read_file('https://github.com/altcoder/philippines-psgc-shapefiles/blob/master/source/2015/Municities.zip')
However, I am getting a driver error:
DriverError: '/vsimem/dff0663a4e584987848e40266f6b73e8' not recognized as a supported file format.
Searching unfortunately did not produce useful clues. I hope someone who knows geopandas or fiona could help.
When loading from GitHub, you need to pass a link to raw version of zip file. Otherwise, it links to GitHub page, not the file.
gpd.read_file('https://github.com/altcoder/philippines-psgc-shapefiles/raw/master/source/2015/Municities.zip')

running joblib.Parallel(mlxtend) does not scale in cloud-ml

Im running a job using the mlxtend library. Specifically the sequential_feature_selector that is parallelized using joblib.Parallel source. When I run the package on my local computer it uses all the available CPUs, but when i send the job to cloud-ml it only uses one core. It doesn't matter what is the number that i put in the n_jobs parameter. I´ve also tried with differents machine types but same thing happen.
Does anybody know what the problem might be ?
For anyone that might be interested, we solve the problem fixing the sklearn version in the setup.py to the 0.20.2. we had sklearn in the packages before, but without a version.
#setup.py
from setuptools import find_packages
from setuptools import setup
REQUIRED_PACKAGES = ['joblib==0.13.0',
'scikit-learn==0.20.2',
'mlxtend']

Go Wants to Import Package From Comment [duplicate]

New Go programmer here -- apologies if this is well worn territory, but my google searching hasn't turned up the answer I'm looking for.
Short Version: Can I, as a programmer external to the core Go project, force my packages to be imported with a specific name. If so, how?
Long Version: I recently tried to install the bcrypt package from the following GitHub repository, with the following go get
go get github.com/golang/crypto
The package downloaded correctly into my workspace, but when I tried to import it, I got the following error
$ go run main.go main.go:10:2: code in directory /path/to/go/src/github.com/golang/crypto/bcrypt expects import "golang.org/x/crypto/bcrypt"
i.e. something told Go this package was supposed to be imported with golang.org/x/crypto/bcrypt. This tipped me off that what I actually wanted was
go get golang.org/x/crypto/bcrypt
I'd like to do something similar in my own packages — is this functionality built into Go packaging? Or are the authors of crypto/bcrypt doing something at runtime to detect and reject invalid package import names?
Yes it's built in, I can't seem to find the implementation document (it's a relatively new feature in 1.5 or 1.6) however the syntax is:
package name // import "your-custom-path"
Example: https://github.com/golang/crypto/blob/master/bcrypt/bcrypt.go#L7
// edit
The design document for this feature is https://docs.google.com/document/d/1jVFkZTcYbNLaTxXD9OcGfn7vYv5hWtPx9--lTx1gPMs/edit
// edit
#JimB pointed out to https://golang.org/cmd/go/#hdr-Import_path_checking, and in the go1.4 release notes: https://golang.org/doc/go1.4#canonicalimports

Resources