Unable to install arcpy module using Pycharm

Viewed 207

I realize this has come up before, but all the responses I've found were for different versions of Arc.

I have followed the steps from this link and set my project interpreter to python c:\Python27\ArcGIS10.4\python.exe. Based from what i've read, that should be set up with Arcpy pre-installed. However, if I look at the packages in the VENV, arcpy isn't listed. I've tried adding it using pip and the pycharm GUI package manager. There isn't a package just named arcpy, the options are:

  • arcpy-metadata
  • arcpy-virtualenv
  • arcpyext
  • arcpylogger

I have successfully installed all of them and they show up in the package list of the project virtual environment. Despite this, I still get "no module named arcpy" as an error when I go to run a script.

Any ideas about where i'm going wrong?

Thanks for your help.

1 Answers

So I've spent a while looking over the issue and using Conda as your project Interpreter is the fix to your issue. I've tested it myself as well. Here are some clear instructions on how to correctly install Conda and set up the environment in Pycharm:

To create a Conda environment:

Ensure that Anaconda or Miniconda is downloaded and installed on your computer, and you're aware of a path to its executable file.

(Refer to the installation instructions for more details.)

Press Meta+Comma to open the project Settings/Preferences.

In the Settings/Preferences dialog Meta+Comma, select Project | Project Interpreter. Click the The Configure project interpreter icon and select Add.

In the left-hand pane of the Add Python Interpreter dialog, select Conda Environment.

The following actions depend on whether the Conda environment existed before.

If New environment is selected:

Specify the location of the new Conda environment in the text field, or click Conda environment location and find location in your file system. Note that the directory where the new Conda environment should be located, must be empty!

Select the Python version from the list.

Specify the location of the Conda executable file in the text field, or click Conda executable location and find location in the Conda installation directory. You're basically looking for a path that you've used when installing Conda on your machine.

Select the Make available to all projects checkbox, if needed.

If Existing environment is selected:

Expand the Interpreter list and select any of the existing interpreters. Alternatively, click Select an interpreter and specify a path to the Conda executable in your file system, for example, C:\Users\jetbrains\Anaconda3\python.exe.

Select the checkbox Make available to all projects, if needed.

Click OK to complete the task.

Related