0

I have quite a few versions of python installed (running macOS). I installed scrapy with pip install scrapy, and it succeeded. When I use it e.g.

scrapy startproject newProject 

I see ModuleNotFoundError: No module named 'six', indicating that I need to install that module (six).

Note: I could easily fix the specific error by installing six for all versions of python installed, but solving that problem isn't what I'm trying to work out here.

Specifically what I'm after here is how to know what version of python a command line utility is using when it runs?

4
  • run python -V learn more: stackoverflow.com/questions/8917885/… Commented Dec 11, 2020 at 2:54
  • Thanks @RayB I always knew of python -V but didn't know for sure if python CLI programs (like scrapy) would always default to that python version given with python -V. If it's as simple as that, please make it an answer Commented Dec 11, 2020 at 2:55
  • @RayB I see here that I shouldn't change that default version. My default is 2.7, but I want scrapy to use 3.9. I have python -V .. 2.7 and python3 -V .. 3.9. Do you know how I can make scrapy (terminal) commands run on python 3.9? Commented Dec 11, 2020 at 2:58
  • Seems I don't need to change the default version, but I can simply tell the CLI which version of python to use with this method. I have no idea if that generalises to other python CLIs, or if it's just for scrapy Commented Dec 11, 2020 at 3:03

2 Answers 2

1

pip install will install package under pythonxxx/site-packages, the concrete location is up to which python version the pip used.

use pip -V to see the pip path and the related Python version. For you question, missing six module, pip install six should be enough, which will install six to the same Python version of scrapy.

After install scrapy, we could also enter scrapy shell, and use the below code to see where scrapy is

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

6 Comments

zsh: command not found: scrapy.__file__
You should enter scrapy shell first, and in the scrapy shell, type scrapy.__file__
Ah good to know. Unfortunately the scrapy shell won't work for me (which is what initially prompted the question above). But good to know in any case.
pip -V will give you the the python version and site-package path. You could see scrapy in the site-package directory.
Also good to know. Another problem with that though, is that I installed both pip install scrapy and pip3 install scrapy :)
|
1

To check the version of python from within a script or the REPL you can use the sys module.

For example:

>>> import sys >>> sys.version '3.8.5 (default, Jul 21 2020, 10:48:26) \n[Clang 11.0.3 (clang-1103.0.32.62)]' 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.