tadm123 tadm123 -4 years ago 117
Python Question

(Python) Virtual env and Scrapy

I'll try to explain this, hopefully it makes sense.

I had installed a virtual env a while ago in the directory:

to do some websites.

I also installed scrapy on the

The problem is that whenever I use the command prompt to run scrapy I need to be in this specific directory, so all the files that scrapy creates are made in here, not in the directory where my project is (that is

So how would I would I be able to run scrapy in the dir that I want? Thanks.

Answer Source

You can create virtualenv in any directory:

virtualenv some/directory
# or windows
virtualenv some\directory

Then you can activate that virtualenv which will change your $PATH environment variables to read python related things from virtual environments directory instead of your system's:

source some/directory/bin/activate
# or for windows

and to deactivate type: deactivate

See more at official documentation of virtualenv

Once you have virtualenv activated when you call scrapy the scrapy of virtual environment will be called instead of system one and any packages you install via pip(if the python version in your virtualenv has it) will be installed to the virtual environment.
You can always test what will run by using:

$ which scrapy
# or for windows
$ where scrapy
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download