0

It gives the error while I am using command line to install the library or package.

As you can see in the attached file (the python_console_in_QGIS, command_line_python, and the library_want_to_follow)

How am I supposed to add the library and packages from command line or inside Notebook? How am I supposed to follow the script (library) to read and write shapefile?

I want to work on shapefile using python.

enter image description here

enter image description here

enter image description here

1 Answer 1

1

In your console example you have opened python and are trying to install the library. You'll need to install the library from outside of python. For QGIS it is easiest to do it from the OSGEO4W Shell (I'm on windows).

enter image description here

Also the install library on pip is called "pyshp". So use this code in OSGEO4W Shell,

python -m pip install pyshp

enter image description here

Then you'll be able to use "import shapefile" in the QGIS console.

2
  • I highly appreciated your feedback. Well, I have tried as you are suggested, it works. I have understood the procedure and functionality regarding installation of pip pyshp using OSGEO4W for QGIS. However, I am afraid, could the reading and writing shapefile scripting work in python notebook (spyder or Jupyter)? Commented Sep 29, 2022 at 7:30
  • 1
    I haven't used pyshp before, but I suspect it's a standalone tool that doesn't need QGIS. So in short, Yes, it would work in a different python environment than QGIS. However, QGIS offers a nice interface to see and verify results. But it all depends on what you want. "Try it and see" is my best advice. Even if it fails you'll learn something new. Commented Sep 29, 2022 at 15:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.