0

I successfully downloaded 'geohash' module using Anaconda. I confirmed it works by testing a line of code in Jupyter notebook. However, in Pycharm, it cannot find the geohash module.

I see the module 'geohash' clearly is in my Anaconda site-packages folder.

enter image description here

I then opened a new python file in Pycharm, and selected "New Conda Environment" as the Project interpreter. You can see the file's interpreter is Anaconda Project Default (Python 3.7) :

enter image description here

enter image description here

And yet, there is no 'geohash' module in the venv in Pycharm, and the module cannot be found:

enter image description here

I'm confused as to why this is so. I would assume all my modules installed with Anaconda would transfer over once the project interpreter is set to Anaconda Python 3.7. What am I doing wrong?

halfer
  • 19,824
  • 17
  • 99
  • 186
DiamondJoe12
  • 1,879
  • 7
  • 33
  • 81
  • Your pycharm is using the GeoHash env inside conda. Can you make sure that the library is installed within that env using `conda list -n GeoHash`. My guess is that you're creating a new env at the start of the project and the library does not exist in that env – razdi Jun 06 '19 at 23:41
  • razdi: good call. It is not in there. If I copy and paste the geohash module into : C:\Anaconda\envs\GeoHash\Lib\site-packages It still doesn't work. Thanks in advance. – DiamondJoe12 Jun 06 '19 at 23:49

2 Answers2

1

When creating a new environment with conda, only the default packages are installed at the beginning. When you created the Geohash environments, it was created with only the default packages conda comes with, and geohash is not a part of that.

You would need to install the geohash package to your particular environment using:

# Install pip in your environment
conda install -n GeoHash pip

# activate your environment
conda activate GeoHash

# Install the package
pip install Geohash

you can read more about managing environments here

razdi
  • 1,388
  • 15
  • 21
  • Thanks, this worked but I have no idea why. First off, the package in question is "geohash", not "Geohash". So I'm not sure why this worked, but it did. Also, what does the -n mean in conda install? And what exactly is the GeoHash environment? Is that something I created in Pycharm, or Anaconda? Thanks. – DiamondJoe12 Jun 07 '19 at 00:02
  • In the second image you provided, look at the Python Interpreter. It points to the env you created in step one and has given it a name `GeoHash` as shown in the brackets. So I installed pip in that env, then activated it. The last install statement was taken from the [GeoHash](https://pypi.org/project/Geohash/) page. – razdi Jun 07 '19 at 00:11
  • I realised you might be working with the `python-geohash` package. If you need that, you would only need to change the last step to install that library. – razdi Jun 07 '19 at 00:15
0

I don't know which version of PyCharm you are using. I think you should choose to use existing environment and point to the environment (could be the conda default) where you installed the package. IIUC, choosing "New Environment" would create a new conda environment which does not have your package.

GZ0
  • 4,055
  • 1
  • 10
  • 21