0

I have some troubles with pip install and I am new to python:

First, this is my python version:

(base) becker@tsf-436-wpa-5-126 ~ % which python3
 /Users/becker/opt/anaconda3/bin/python3

then for example I want to install turfpy, so I do

 pip3 install turfpy

the output to that is

  Requirement already satisfied: turfpy in ./opt/anaconda3/lib/python3.8/site-packages (0.0.6)
  Requirement already satisfied: shapely in ./opt/anaconda3/lib/python3.8/site-packages (from turfpy) (1.7.1)
   Requirement already satisfied: scipy in ./opt/anaconda3/lib/python3.8/site-packages (from turfpy) (1.5.2)
   Requirement already satisfied: numpy in ./opt/anaconda3/lib/python3.8/site-packages (from turfpy) (1.19.2)
   Requirement already satisfied: geojson in ./opt/anaconda3/lib/python3.8/site-packages (from turfpy) (2.5.0)

So In principle, I would assume that everything should work.

Now my python file that I am writing with spyder is in a different folder, you see the directory below, than any of the above.

In fact, running the file, I get

  File "/Users/becker/Desktop/elevation data/pointinpolygon.py", line 1, in <module>
    from turfpy.measurement import boolean_point_in_polygon

   ModuleNotFoundError: No module named 'turfpy'

So I must assume that turfpy is not installed after all.

I apologize in advance if some additional information is missing that I should provide. I am a bit clueless what is going on. However, I would like to understand how to do it with spyder and not first uninstall everything to fix this issue, if that is possible.

18
  • Try “pip3 install xyz”. Then try “python3 file.py” Commented Apr 13, 2021 at 10:25
  • i understand the first command, and it produced the same output as pip install xyz, i do not see where you want me to use the second one. I use spyder. Sorry, I am completely new to python. So without doing the second one, it did not work I think as I still get 'module not found' Commented Apr 13, 2021 at 10:28
  • When you install for non microsoft systems....you can create 2 bin folders. One will be python2 and be labeled python. The other will be python3 and will be labeled python3. When you use python2 the command will be “python filename.py”. When you use python3 the command will be python3 filename.py. Commented Apr 13, 2021 at 10:31
  • 1
    I'd guess, that you're not using the same python in the anaconda prompt as in spyder. Try to type "python" in the anaconda prompt and then do "import turfpy". Does it work? Commented Apr 13, 2021 at 12:37
  • 1
    How do you start sypder? Try to start it from command line. Then it should start in the base environment. Commented Apr 13, 2021 at 12:45

1 Answer 1

1

Make sure, that your Spyder is using the "base" anaconda environment.

From: https://docs.spyder-ide.org/current/faq.html :
In the anaconda prompt: You should activate your conda environment (in your case you don't have to, since you use the "base" environment) and start spyder typing "spyder".

One thing, hard to understand at the beginning, is that you can have multiple python instances installed on your machine. Anaconda is a great tool to manage the different "environments" having different python versions installed with different package combinations.

In your case Spyder uses a different interpreter as in your anaconda prompt, where you installed the package. Here, it is explained how to check, which Python interpreter is used by Spyder: https://stackoverflow.com/a/54237704/2196531

Sign up to request clarification or add additional context in comments.

Comments

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.