scrapy requires python 2.7 but i already have - python

first of all i'm working on osx 10.6.8
i installed scrapy using the command:
sudo easy_install Scrapy
and everything seemed working fine. but when i try to create a new project using
scrapy startproject tutorial
i only get
Scrapy 0.22.2 requires Python 2.7
i tried this solution, but i get the same problem.
how could i fix this?
EDIT: i think i have understood the problem: easy-install referrs to an older version of python (2.6) that it is in my system under /Library/Python/2.6 (probably it was pre-installed), so i installed scrapy for python 2.6! that's why i get the error. but now i don't know how to install scrapy for the right version of python!

Execute
which python
and
python --version
my guess is scrapy is not linking to python2.7 by default.

Please, open /Library/Frameworks/Python.framework/Versions/2.7/site-packages/scrapy/__init__.py and insert at line 14:
13 if sys.version_info < (2, 7):
14 print(sys.version_info)
15 print("Scrapy %s requires Python 2.7" % __version__)
16 sys.exit(1)
then scrapy startproject tutorial and show us the output

i solved following [this][1] guide and executing again:
sudo easy_install scrapy
now it works!

Related

How can I show the django version in pycharm?

I want to see the django version in my Pycharm terminal, but I don't get the correct method.
I tried bellow methods in pycharm terminal:
1) django --version and django version
2) import django, and print the version by:
import django
print django.VERSION
But I still can not get it.
If you cannot print the Django version from the python console in Pycharm, go to settings>Project:project_name>project Interpreter and from the list of installed packages see the installed Django and it's version for that project.
You can run pip freeze too. Just filtering the results with grep...
pip freeze | grep Django
You're trying to access a version attribute, but you can find out Django's version using the get_version method:
import django
django.get_version()
In the terminal you can use bellow command to check the version of django:
python -m django --version
If you want to use your second method, just like this bellow command:
python -c "import django; print(django.VERSION)"
(1, 11, 2, u'final', 0)
go to setting > project > project Interpreter and install Django package
then run the code
import django
print(django.get_version())
Run pip freeze > requirements.txt
A .txt file with that name will be created automatically, open the file and check for the django version and other previously installed libraries.
I do not know about pychram but the most efficient way to query the django version without importing django globally would be this:
from django import VERSION as DJANGO_VERSION
if DJANGO_VERSION >= (2, 0):
pass
What was not proposed in this question which is something similar:
How to check Django version
I had the same question. The solution is simple.
Just create a project, open settings.py file and observe the first comment lines. You will see the version info in there as displayed below:
Image of settings.py that shows the Django version
I found the solution here.
Simplest is
import django
print(django.get_version())
Using the following command on terminal will give you django version
python -m django --version
Or
You can go to the interactive python prompt and use the command
import django
print(django.get_version())
or using pip freeze and grep you can also get the django version
pip freeze | grep Django

how to install scrapy under python3

i have installed twisted,lxml,scrapy successively using cmd.When i import scrapy in cmd window,it doesn't raise exception.
but when i import scrapy in spyder,it raise exception like following:
i wonder if there are some solutions?Thanks in advance.
I am assuming you have installed scrappy using pip under windows correct?
The issue at hand has everything to do with python and spyder being able to see the install. I had similar issues with opencv when first installing.
The get around this, I compiled both opencv and python together and installed them.
I vote you try and perform the install using the python console in spyder.
pip install scrampy
Did you install the python 3 upon python 2?
If true, the scrapy may be integrated to python 2.
confirm the version with this instruction in the command line.
python --version
If it says Python 2.7.x, you tested on the python 2 when trying with cmd.
Let me know you have both of version on your computer.

Python 2.7 Scrapy library fails to install "properly" on Yosemite

Okay so first things first, I haven't tried any other library installs on my Mac (running Yosemite V10.10) so that might be why I'm having trouble, but regardless I'm having difficulties running Scrapy. I've already figured out a few things, such as you need Python 2.7 to install it, which I have and when I type:
$ python -c 'import scrapy; print("%s.%s.%s" % scrapy.version_info)'
It returns 0.24.0 which seems like it's installed however I cannot use any commands. I was following a tutorial and the next line of code it asks for is to create this class:
import scrapy
class MinimalSpider(scrapy.Spider):
"""The smallest Scrapy-Spider in the world!"""
name = 'minimal'
Which I do then to run this piece of code:
scrapy runspider minimal.py
Name of file is minimal.py and this returns a
scrapy: command not found error.
Now after a little bit of debugging, I switched tutorials to this one: http://doc.scrapy.org/en/latest/intro/tutorial.html#intro-tutorial , however when I get to the first real piece of code and run:
scrapy startproject tutorial
it says the same thing.
My suspected resolution:
Now I've already checked and there is nothing in my "username"/Library/Python/2.7/lib/python/site-packages folder - as this is where scrapy was supposed to have been downloaded, actually there's not even a Library folder, as I downloaded scrappy with the line pip install --user Scrapy==0.24 , so it saved it to my user folder, if I move one folder up and go to the main Library/Python/2.7 folder there's no lib file so I'm not really sure where Scrapy downloaded to. I'm not sure if this is causing my error, as I do think I have Scrapy installed.

python 2.5 uninstalled, 2.7 and 3.4 installed - /2.5/bin/python: bad interpreter: No such file or directory

I have uninstalled python 2.5 and installed 2.7 and 3.4 on my Mac OS X 10.9.2.
Somehow when i try to install a new module, i am getting the following error
Thomass-MacBook-Pro:dev thomas$ pip install lxml
-bash: /usr/local/bin/pip: /System/Library/Frameworks/Python.framework/Versions/2.5/bin/python: bad interpreter: No such file or directory
I googled and tried things for hours, played around with symlinks but somehow the system still thinks that 2.5 is the standard version.
Check what Python version are using pip command
head -1 /usr/local/bin/pip | sed s/#\!//g
In my OSX, the python is:
/usr/bin/python
Then, check that python version:
/usr/bin/python -V
If you get 2.5 then something was wrong with your python runtime upgrade, replace the first line in /usr/local/bin/pip by the python2.7 executable. This is not elegant, but It should work temporary until you get clear your system
This sounds a bit odd, but in googling for my similar error* , I found this post and decided to try restarting my machine. That actually made everything start working, which makes me think there was a caching issue. I see this issue opened was about a week ago for you, so hopefully you're in better shape now.
* virtualenv-2.7 thought that was associated with a recently uninstalled python3.4, but virtualenv correctly was associated with 2.7

How can I update Python on Mac OS and have RubyGems use the new version?

I am having serious issues trying to download the "therubyracer" gem. I think the problem is that I do not have a working libv8 library to create the gem.
I think I do not have a working libv8 because my RubyGems keeps trying to use "Python 2.5.6", which is too old to gem install libv8. I tried countless ways to update the Python that RubyGems uses, however, I cannot figure it out.
Here is what I have done thus far. I went to http://www.python.org/download/releases/3.3.2/ and downloaded "(Mac OS X 64-bit/32-bit Installer (3.3.2) for Mac OS X 10.6 and later 2.)".
Upon completion of the download, I ran:
gem install libv8 --version 3.11.8.17
Yet, I still received the same error. I noticed the output still said:
"Using Python 2.5.4"
Despite downloading a newer Python version, it is not being used. So how do I change the version of Python that the "gem" command uses? I searched and discovered "virtualenv," which appears to be a good Python manager, however I am a bit at a dead end now. Any help or suggestion?
If libv8 uses the python command from the command line, this should apply:
If you do not care what python2 is installed, you can do this in the command line:
type python # this gives you the path of the python command
python is /usr/bin/python
type python2.7
python is /usr/bin/python2.7
Then you can copy one over the other
cp /usr/bin/python2.7 /usr/bin/python
You can safely copy python2.7 there because it is compatible with older versions.
Suggestions?

Categories