问题
I'm trying to install Scrapy on windows 7. I'm following these instructions:
http://doc.scrapy.org/en/0.24/intro/install.html#intro-install
I’ve downloaded and installed python-2.7.5.msi for windows following this tutorial https://adesquared.wordpress.com/2013/07/07/setting-up-python-and-easy_install-on-windows-7/, and I set up the environment variables as mentioned, but when I try to run python in my command prompt I get this error:
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\>python
‘python’ is not recognized as an internal or external command,
operable program or batch file.
C:\> python ez_setup.py install
‘python’ is not recognized as an internal or external command,
operable program or batch file.
C:\>
Could you please help me solve this?
回答1:
ur
is python2 syntax you are trying to install an incompatible package meant for python2 not python3:
_ajax_crawlable_re = re.compile(ur'<meta\s+name=["\']fragment["\']\s+content=["\']!["\']/?>')
^^ python2 syntax
Also pip is installed by default for python3.4
回答2:
Scrapy doesn't work with Python 3 as mentioned in their FAQ
you should install Python 2.7
回答3:
Step By Step way to install scrapy on Windows 7
- Install Python 2.7 from Python Download link (Be sure to install Python 2.7 only because currently scrapy is not available for Python3 in Windows)
- During pyhton install there is checkbox available to add python path to system variable click that option. Otherwise you can add path variable manually.
You need to adjust PATH environment variable to include paths to the Python executable and additional scripts.
The following paths need to be added to PATH
C:\Python27\;C:\Python27\Scripts\;
If you have any other problem in adding path variable please refer to this link
3. To update the PATH open a Command prompt in administration mode and run: :\python27\python.exe c:\python27\tools\scripts\win_add2path.py
.Close the command prompt window and reopen it so changes take effect, run the following command, to check ever thing added to path variable. python -–version
which will give output as Python 2.7.12
(your version might be different than mine) pip --version
which will give output as pip 9.0.1
(your version might be different than mine)
4. You need to install visual basic C++ Python complier. You can download that from Download link
5. Then you install to install libxml which python library used by scrapy. You download it by writing a command pip install libxml
into command prompt.
but if you face some problem in pip installation you can download it from http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml download libxml package according to your system architecture. Open command prompt into that download directory and pip install NAME_OF_PACKAGE.whl
6. Install pywin32 from Download link. Be sure you download the architecture (win32 or amd64) that matches your system
7. Then open command prompt and run this command pip install scrapy
I hope this will help in successful installing scrapy
8. For Reference use can your these links Scrapy official Page and Blog on how to install scrapy on windows
回答4:
How to install Scrapy 1.4 on Python 3.6 on Windows 8.1 Pro x64
pip install virtualenv
pip install virtualenvwrapper
pip install virtualenvwrapper-win
mkvirtualenv my_scrapy_project
I advice to use virtualenv. In my example I am using name my_scrapy_project for my virtual environment. If you want to go out of virtualenv, simply type deactivate, if you want to go back into, simply type workon my_scrapy_project.
- Go to: http://landinghub.visualstudio.com/visual-cpp-build-tools
- Click on button: Download Visual C++ Build Tools 2015
Install these tools.
Go to: https://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml
- Find and download: lxml-4.1.1-cp36-cp36m-win32.whl
- Move this file to your active directory in commandline and install it:
pip install lxml-4.1.1-cp36-cp36m-win32.whl
pip install scrapy
And that is all, it should work.
来源:https://stackoverflow.com/questions/28150433/installing-scrapy-python-and-easy-install-on-windows-7