0

I have installed Anaconda and downloaded Scrapy through it. Now when I want to start a new Scrapy project using Pycharm, it says that

Scrapy is not recognized as an internal or external command, operable program or batch file.

What should I do?

James Z
  • 12,209
  • 10
  • 24
  • 44
  • Usually, it happens because the variable is absent in the system "Environment variables". I have my scrapy.exe file in C:\ProgramData\Anaconda3\Scripts, please check yours. – apet May 03 '20 at 12:49
  • You have to check in which conda environment you have installed scrapy and select that environment when creating your PyCharm project. Or create a new one and install scrapy in your new environment (from the terminal of PyCharm, for example). – Barrendeitor May 03 '20 at 13:12
  • When I install directly through PyCharm, Error is shows which asks for Microsoft visual studio installation. I have tried installing the visual studio but still cant download. That is why I chose the Anacona route. – user3769820 May 03 '20 at 13:15
  • Are you using the correct Python installation in pycharm? – AMC May 09 '20 at 02:58

1 Answers1

0

Assuming it's a virtual environment problem ...

First, it should be clarified that Anaconda uses a virtual environment system similar to pyenv or virtualenv: check this to know more.

By default, Anaconda has a "base" environment, which is the one I assume you have installed scrapy on.

You can create new environments with:

conda create -n <env_name> python=<version>

Having clarified this, you have to take into account that what is installed in an environment is only available in that environment.

When creating a new project in PyCharm, it creates a new environment by default (with virtualenv, pipenv, or whatever depending on how it is configured by default).

If you want to use a conda environment you must add it to PyCharm and select it as an interpreter in your PyCharm project.

Then, what you install in that environment ...

conda install -c conda-forge scrapy
pip install scrapy

... will be available in the terminal and / or the python interpreter from PyCharm.

Barrendeitor
  • 506
  • 1
  • 3
  • 14
  • Hi, thanks a lot. This has solved my query. The first command doesnt solve it, but the "pip install scrapy" downloads everything properly in the venv and now it works like smoothy – user3769820 May 04 '20 at 03:21
  • Nice! The second command install the scrapy binary, while the first one install the scrapy python library which let you `import scrapy`. – Barrendeitor May 04 '20 at 11:32
  • @user3769820 Be very careful when using pip inside of a Conda environment, see https://www.anaconda.com/blog/using-pip-in-a-conda-environment. – AMC May 09 '20 at 02:58