Installing shapefile / shapelib not found via conda or pip - python

I am trying to read shapefiles to view suburbs in a city following this tutorial using windows 8, Anaconda and iPython.
I tried "conda install shapefile" and "pip install shapefile" in command prompt, both returning "Error: No packages found matching: shapefile".
Besides that I tried adding it manually following these links [1]How to import a module given the full path?
[2]Import python module NOT on path. However I am getting permission errors which suggests I am not importing them correctly anyway.
Any suggestions on how to proceed or best practices are appreciated.

try
pip install pyshp
in your cmd.
that is the name of you library as far as I can see, see https://pypi.python.org/pypi/pyshp
conda only works for these http://docs.continuum.io/anaconda/pkgs.html packages.
For the ones not in the list you need to use pip install. It can be confusing as the name of the library on pypi (this is where pip goes to download it) is often, but not always the same as the import name, so if conda and pip don't work, first try to google to make 100% sure that your library is not on pypi, because most respectable libraries are...

Related

Cannot Install PIP Packages on W10

I´ve tried all posible ways, uninstalling python and pip and reinstalling them, creating a virtual environment, changing the settings to "true", checking that my needed folders are in the PATH, checking the system/user priviligies to allow all. And yet, I am still getting this OSError that cannot connect while trying to collect the package, see in picture below, I have used all the ideas listed in: https://bobbyhadz.com/blog/python-could-not-install-packages-due-to-an-oserror-winerror-2-system-cannot-find-file-specified, but as I wrote before I cannot install new pip packages:
I tried all the ideas listed here and yet no result:
https://bobbyhadz.com/blog/python-could-not-install-packages-due-to-an-oserror-winerror-2-system-cannot-find-file-specified
I want to be able to install pip packages

Installed anaconda python libraries cannot be imported

I'm setting up a Python/conda enviroment on Ubuntu. I installed some common Python libraries such as tensorflow via conda install or pip install. Via pip show ... I found out they are all installed in the following folder: /home/anaconda3/lib/python3.8/site-packages/. However, when running them in Spyder I get the ModuleNotFoundError: No module named 'tensorflow' error message, for about every library (including matplotlib).
How can I fix this? I read this post about how they apparently need to be installed in /home/anaconda3/envs/[name env]/lib/python3.7/site-packages/ (/home/anaconda3/envs/ is an empty folder for me). However, the quick fix mentioned doesn't work for me.
Is there some way to add /home/anaconda3/lib/python3.8/site-packages/, use it as default, or is their a way to reinstall packages such that they will work?
Curiously enough, I did manage to get pygrib working via conda install -c conda-forge pygrib=2.0.1, but I'm not sure whether this is the way to go for all packages and would like to know what this does differently.

Trying to install new libraries on Spyder (Python 3.7)

I am new to python and I am having trouble downloading some new libraries that don't appear to be pre-installed. The names of them are rasterio and retrying. I continuously get an invalid syntax error, and I have tried using some different suggestions found online.
pip install rasterio
Above is the way I was attempting to do it, and I also tried without the pip in there, but neither option worked. I am new enough to the language that troubleshooting is very difficult. Any help is greatly appreciated!
There are several ways to install rasterio, using anaconda you have the documentation here: https://anaconda.org/conda-forge/rasterio
If you are on windows installing rasterio using pip install can be difficult since it requires binary wheels, but here is the tutorial: https://rasterio.readthedocs.io/en/latest/installation.html
I advise you to use linux since it is much easier to install packages, you can either install a dual boot or a virtual box.
I suppose you are using Spyder IDE with Anaconda. So, to install rasterio package you can open anaconda prompt and type:
conda install -c conda-forge rasterio
For further information about package installation check out this link.
Also, to install any conda packages just google it once, you will find instructions to install it mostly in anaconda's official site.
Edit:
Please remove the rasterio package once. And install it again, see if works. If it doesn't work create a new environment like: conda create --name myenv. Then install rasterio again.
If this still doesn't work, try to install rasterio from here like conda install -c ioos rasterio.

Provide a path to gdal-config using a GDAL_CONFIG environment variable error while attempting to install Fiona

This is the error I receive:
A GDAL API version must be specified. Provide a path to gdal-config
using a GDAL_CONFIG environment variable or use a GDAL_VERSION
environment variable.
after running the command:
pip install Fiona
from the command line. I had to install GDAL manually from a wheel file found here (python 3.7 32bit): https://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal
I have looked for a solution to this but the suggested solution is to uninstall and reinstall GDAL through Conda, and I am unable to use Conda.
If anyone could tell me simply where the gdal-config file is that would be fantastic so I can add it to my environment variables. A solution is also very welcome.
This doesn't show where the gdal-config file is, but solves your fiona issue.
First download the relevant wheel file (looks like Fiona‑1.8.4‑cp37‑cp37m‑win32.whl is what you're after and it's available at the site you linked: https://www.lfd.uci.edu/~gohlke/pythonlibs/#fiona).
Then use this command (changing the path to where you file is):
pip install C:/path/to/Fiona‑1.8.4‑cp37‑cp37m‑win32.whl
More info here: https://pip.pypa.io/en/latest/user_guide/#installing-from-wheels
and How do I install a Python package with a .whl file?
2 years later, but I thought I would share some insight into this question for anyone who happens on it.
I installed GDAL using https://trac.osgeo.org/osgeo4w/#QuickStartforOSGeo4WUsers. You don't need to install the osgeo GUI or anything, you can manually select what packages you want to install. Additionally it allows the easy install of a bunch of other useful related binaries that are used by many other packages (the one I specifically was having trouble with was cartopy).
After this, start adding things to your path envvar (for windows). For me, I added:
C:\OSGeo4W64\bin and C:\OSGeo4W64\include to my path envvar and was able to get everything working after that. I could simply pip install at the command line with no issue.
This was done as an alternative to conda, as conda took 12 hours to tell me it couldn't install the package.

Installing gspread on OSX Anaconda for Python 3.4.3

I've tried a bunch of different variations of this out of the terminal and so far no joy. I'm trying to read Google Spreadsheets and would love to do it via Anaconda. Anaconda works great, but installing the gspread package so far is no joy. Here are some of the variations of what I've tried:
conda install gspread
This just results in Error: No packages found in current osx-64 channels matching: gspread
which makes me realize that route is probably just for stuff already available via Anaconda. So I tried downloading and unzipping gspread from here: (gspread on github)
And then navigating to the folder cd /Users/jlalonde/Downloads/gspread-master/gspread/
And trying to install, via a bunch of different variations from there. Example:
conda install setup.py
...results in same error message:
Error: No packages found in current osx-64 channels matching: setup.py
So there may be a fast-and-easy way to do it, I'm just not using the right combination of commands to get it going. Here is hoping it is possible. Any Anaconda experts out there who can help? Maybe there is something other than gspread that is comparable? That would be OK, too.
pip and conda don't play well together
If you want to load using conda, run
conda install -c conda-forge gspread
You could try it with pip:
pip install gspread

Categories

Resources