Hot answers tagged

9

To follow theJones and user5584, PyCharm 4 now stores the setting under "Project Interpreter" rather than "Python Interpreters." With all projects closed, and PyCharm still open, go to "Configure" and then "Settings". "Project Interpreter" is under the "Default Project" menu on the left. Click the settings gear in the upper-right, and then "Add Local." ...


7

I’ve found the solution of my main question with help of this answer. If you need to add some external library, first of all check where it is placed (if it is possible of course). I opened Python console in QGIS and inserted: from processing.core import AlgorithmProvider AlgorithmProvider.__file__ output: '/usr/share/qgis/python/plugins/processing/...


7

I figure it out! CALL %OSGEO4W_ROOT%\bin\o4w_env.bat called on all .bat files in %OSGEO4W_ROOT%\etc\ini\ and there is the file: python-core.bat So by changing from python27 to python36 in C:\osgeo4w64\etc\ini\python-core.bat Pycharm find all dependencies :) EDIT 2018-02-19: After a while away from qgis-master I went back today and had some problems with ...


6

There is a Help page entitled Importing ArcPy that explains this - I encourage you to visit that page which has more detail than I am quoting: When using an import statement, Python looks for a module matching that name in the following locations (and in the following order): Paths specified in the PYTHONPATH system environment variable A set ...


5

You can do this in the project Structure setting. Just add it as an sdk and it should work. I use intelliJ but pycharm should be the same. PyCharmDocs Add this (Use your path) for the sdk path C:\Python26\ArcGIS10.0\python.exe Give it a name and you should be good. Adding it as a global sdk you should be done and get the code completion.


5

QgsVectorLayer class has a fields method for it. Using the QGIS Python console you can try this code (the current layer should be a vector layer (instance of QgsVectorLayer)): >>> layer = iface.activeLayer() >>> layer <qgis._core.QgsVectorLayer object at 0x7f5e031ccc18> >>> layer.fields() <qgis._core.QgsFields object at ...


4

I found it, it was just a small tricky approach. in OsGeo4w website says you have to install QGIS by Osgeo4w setup which it sets all kinds of path variables for you ... ( it was NOT entirely true, in my case) leave your PATH, Path, PYTHONPATH, PYTHONHOME to where it's functional for all modules unless qgis's. I removed QGIS standalone and installed QGIS ...


4

Basile, as a P.S. to my comment, my batch file (pyqgis.cmd) looks like this: @echo off SET OSGEO4W_ROOT=C:\OSGeo4W64 call "%OSGEO4W_ROOT%"\bin\o4w_env.bat call "%OSGEO4W_ROOT%"\apps\grass\grass-7.4.0\etc\env.bat @echo off path %PATH%;%OSGEO4W_ROOT%\apps\qgis\bin path %PATH%;%OSGEO4W_ROOT%\apps\grass\grass-7.4.0\lib path %PATH%;C:\OSGeo4W64\apps\Qt5\bin path ...


4

If you look at step 23 in the tutorial you'll see some lines in the run method: if self.first_start == True: self.first_start == False self.dlg = SaveAttributeDialog() You need to find those lines and make sure they are called before you try to use the dialog anywhere. Also check that the name matches the name of your dialog (probably something ...


3

The Python installation of ArcGIS is not "standard" 1) you need first to install pip 2) then in theory you can install SciPy but SciPy is not a pure Python module, it needs compilation of C files and Windows has no compiler by default. You can try the Microsoft Visual C++ Compiler for Python 2.7 or a version of Christoph Gohlke Unofficial Windows ...


3

[I'm guessing based on available information]: Your problem is with what you're passing in when running it in a an IDE (outside the app) try: arcpy.geocoder_geocoder('gc_01', 'J:/Postal/Postal/99_Geocode/01/composites/composite_1', 'J:/Postal/Postal/99_Geocode/01/composites/composite_2', 'J:/Postal/Postal/...


3

The community edition doesn't support remote debugging, meaning you can't test your plugin while running in QGIS. You can use Winpdb (cross platform despite the name) to remotely debug a QGIS plugin. See: http://winpdb.org/ From the PyQGIS Programmers Guide (http://locatepress.com/ppg): In your code, add lines to enable debugging: import rpdb2 rpdb2....


3

The batch script from the A Quick Guide to Getting Started with PyQGIS on Windows as described in the comments and by @PolyGeo maybe outdated. The SDK seems invalid appear in PyCharm 2016.3 by using the script. I suspect it needs more paths to be included especially (maybe) pip.exe path that exist in %OSGEO4W_ROOT%\apps\Python27\Scripts. So I include that ...


3

From the comments it looked like the asker of this question was able to resolve their problem by reading a blog posting entitled A Quick Guide to Getting Started With PyQGIS on Windows. In that blog the advice offered seemed to be: We only changed the last line, adding the start statement with the path to the IDE (PyCharm). If you save this to ...


3

SAGA has a command-line interface, so once you have it installed and on your system path, you can access the tools directly using a command line call from Python (I do this all the time with R, the process is very similar). Here's an example of calling the help function for SAGA: from subprocess import call call(['saga_cmd', '-h']) and here's the help for ...


3

Try to use this .bat file to launch PyCharm: @ECHO off set OSGEO4W_ROOT=C:\OSGeo4W64 call "%OSGEO4W_ROOT%\bin\o4w_env.bat" call "%OSGEO4W_ROOT%\bin\qt5_env.bat" call "%OSGEO4W_ROOT%\bin\py3_env.bat" path %OSGEO4W_ROOT%\apps\qgis\bin;%PATH% set QGIS_PREFIX_PATH=%OSGEO4W_ROOT%\apps\qgis set GDAL_FILENAME_IS_UTF8=YES set VSI_CACHE=TRUE set VSI_CACHE_SIZE=...


2

A lot has changed since the recent update hence answering this to align with the PyCharm version 2018 interface: Close all the projects by selecting File>Close projects Select Configure gear icon>Settings Select Project Interpreter and click on another gear icon next to Project Interpreter dropdown and select 'Add' Select 'existing environment' and locate ...


2

You seem to have misinterpreted a suggestion offered in a comment. Instead of: inputOne = "C:\Users\DELL\AppData\Local\Temp\tmpA378\tmpA379.gdb\PerpendicularLine" inPointElevations = inputOne print os.path.dirname(inputOne) pathAfterJoin = os.path.join(inputOne) arcpy.TopoToRaster_3d(inPointElevations,"D:\\Temp\\topo1234") try using: inputOne = r"C:\...


2

As you can see at Terminology for distinguishing ArcPy installed with ArcGIS 10.x for Desktop from that which comes with ArcGIS Pro? there is a difference between the ArcPy functions available with ArcGIS Pro (Python 3.x) and ArcGIS 10.x for Desktop (Python 2.x). It looks like you are trying to use the ArcGIS Pro tool named Split By Attributes in the ArcPy ...


2

QGis has installed it's own version of Python. So you have two installations. The PYTHONPATH is used to specify which directories to scan for source modules. In this case PyCharm appears to be confused as to which installation to use. But you should be able to configure it as needed. sys.path is initialized from PYTHONPATH Both versions of your PyCharm ...


2

Try editing your code with the following: Replace app = QtGui.QApplication with app = QApplication([], True) Move the above line after you have set your prefix path. Add from PyQt4.QtGui import QApplication when importing PyQt4 modules Remove 11 in the line window_frame = QtGui.QFrame(window) 11 Running the above works for me, here is the code I used: ...


2

After half a day I was able to sort out the issue by downloading a patch from ESRI website, which addresses this issue: https://support.esri.com/en/download/7579 Anyway, problem is solved. It was driving me mad :)


2

At least i managed to start Pycharm with an OSGEO4W Environment. My PyCharm is 2017.3, 64bit-Edition. My OSGEO4W is 32bit and uses QGIS3/Python3. I think it will be easy to change it for QGIS2/Python2.7 or anything with 64bit. I do start PyCharm with the batch-file in PyCharms bin directory, called by a custom Script to set the needed environment variables, ...


2

I would just call the command line argument via os.system. Here is an example of running SAGA's Gaussian Filter tool via Python and os.system: import os input_file = "/some/raster.sgrd" output_file = "/some/other_raster.sgrid" os.system("saga_cmd grid_filter 1 -INPUT '" + input_file + "' -RESULT '" + output_file + "' -SIGMA 1.0 -MODE 1 -RADIUS 5") That ...


2

I use such *.cmd file (different than yours) to start PyCharm. Try to use it. @ECHO off set OSGEO4W_ROOT=C:\OSGeo4W64 call "%OSGEO4W_ROOT%\bin\o4w_env.bat" call "%OSGEO4W_ROOT%\bin\qt5_env.bat" call "%OSGEO4W_ROOT%\bin\py3_env.bat" path %OSGEO4W_ROOT%\apps\qgis\bin;%PATH% set QGIS_PREFIX_PATH=%OSGEO4W_ROOT%\apps\qgis set GDAL_FILENAME_IS_UTF8=YES set ...


1

On Arch Linux (but it should work on Ubuntu too), I use this python script that at the loading of QGIS checks if anyone is listening on port 53100. If so, it tries to import pydevd from the pycharm's directory and tries to connect to the remote debugger. import psutil def is_listening_local(port=53100): """Return True if someone is listening on the ...


1

found what the problem was! for using qgis python version in windows, set PYTHONHOME = C:\Program Files\QGIS 2.18\apps\Python27 And set PYTHONPATH to where the packaging is: PYTHONPATH = C:\Program Files\QGIS 2.18\apps\Python27\Lib ***and most important is the system variable PATH which should point to both directories above as well as where the ...


1

I found a solution for my problem . There is the code: from qgis.core import * # supply path to qgis install location QgsApplication.setPrefixPath("C:\\Program Files\\QGIS Lyon\\apps\\qgis", True) # create a reference to the QgsApplication, setting the # second argument to False disables the GUI qgs = QgsApplication([], True) # load providers qgs.initQgis(...


1

what I have noticed is that its not working until the first run. Simply start your script with Import arcpy and run it... then you will have Autocomplete functionality enabled. Looks like, pycharm needs to load arcpy library first,


Only top voted, non community-wiki answers of a minimum length are eligible