0

I am trying to locally run an existing Django 1.9 project from my own github on a Mac.

https://github.com/shanegibney/djangoForum.git

Since posting to github over a year ago I've moved to a mac from linux, Fedora.

I've been following instructions from,

How to run cloned Django project?

$ mkdir djangoForum

$ cd djangoForum

$ virtualenv

$ git clone https://github.com/shanegibney/djangoForum.git

$ source env/bin/activate

$ cd djangoForum

$ pip install -r requirements.txt

This is where I get the following error,

(env) shanegibney at Shanes-MacBook-Pro in ~/djangoForum/djangoForum on master*
$ pip3 install -r requirements.txt
Collecting arrow==0.7.0 (from -r requirements.txt (line 1))
  Using cached arrow-0.7.0.tar.gz
Collecting beautifulsoup4==4.4.1 (from -r requirements.txt (line 2))
  Using cached beautifulsoup4-4.4.1-py3-none-any.whl
Collecting disqus==0.0.4 (from -r requirements.txt (line 3))
  Using cached disqus-0.0.4.tar.gz
Collecting Django==1.10.2 (from -r requirements.txt (line 4))
  Using cached Django-1.10.2-py2.py3-none-any.whl
Collecting django-allauth==0.25.2 (from -r requirements.txt (line 5))
  Using cached django-allauth-0.25.2.tar.gz
Collecting django-allauth-bootstrap==0.1 (from -r requirements.txt (line 6))
  Using cached django-allauth-bootstrap-0.1.tar.gz
Collecting django-emoticons==1.1.2 (from -r requirements.txt (line 7))
  Using cached django_emoticons-1.1.2-py2.py3-none-any.whl
Collecting django-forms-bootstrap==3.0.1 (from -r requirements.txt (line 8))
  Using cached django-forms-bootstrap-3.0.1.tar.gz
Collecting django-tinymce==2.3.0 (from -r requirements.txt (line 9))
  Using cached django-tinymce-2.3.0.tar.gz
Collecting evernote==1.25.1 (from -r requirements.txt (line 10))
  Using cached evernote-1.25.1.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/8z/jqnd9kp531q6h12pj95z0kwc0000gn/T/pip-build-_kcvo5hn/evernote/setup.py", line 6
        exec x
             ^
    SyntaxError: Missing parentheses in call to 'exec'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/8z/jqnd9kp531q6h12pj95z0kwc0000gn/T/pip-build-_kcvo5hn/evernote/

The error is the same whether I use pip or pip3.

$ pip --version pip 9.0.1 from /Users/shanegibney/djangoForum/env/lib/python3.6/site-packages (python 3.6)

$ python --version

Python 3.6.3

$ which python

/Users/shanegibney/djangoForum/env/bin/python

$ which python2

returns nothing

The requirements.txt file is here,

https://github.com/shanegibney/djangoForum/blob/master/requirements.txt

Can anyone see why I get the error when trying to install requirements.txt?

Tried changing my virtualenv to Python2,

$ virtualenv -p python2 v

The path python2 (from --python=python2) does not exist

Shane G
  • 3,129
  • 10
  • 43
  • 85

2 Answers2

0

The Evernote SDK for Python only supports Python 2. You get the error because your virtual environment in Python 3. When you have activated the virtualenv, pip will install into the Python 3 virtualenv as well.

The README has a link to an experimental repository for Python 3. You could try installing this instead, but you may find other incompatibilities in your project. Your other option is to run your project in Python 2.

If you decide to use Python 2, then make sure you use Python 2 when you create your virtualenv, e.g.

virtualenv -p python2 v

Then activate your virtualenv before installing your requirements.

Alasdair
  • 298,606
  • 55
  • 578
  • 516
  • 1
    I don't think there is `python2`. Only `python3` is explicitly marked, otherwise it is just `python`. But the OP can check that with `which python`. – cezar Dec 21 '17 at 10:34
  • 1
    The OP is using a Mac, and `python2` works for me on a Mac. – Alasdair Dec 21 '17 at 10:36
  • 1
    Oooops! I didn't even think beyond Linux. Then, if at all, he should use `which python2` instead of `which python`. – cezar Dec 21 '17 at 10:39
  • 2
    The `virtualenv -p python2 v` command is just an example. The key point is that the virtualenv needs to use Python 2. In some cases (e.g. in a Python 3 virtualenv) `python` may be Python 3. The advantage of `-p python2` is that `python2` should always be Python 2. – Alasdair Dec 21 '17 at 10:49
  • @cezar `python2` works for me on Ubuntu 16.04 as well, so it's not just on Mac. – Alasdair Dec 21 '17 at 10:51
  • Do I need to sort of remove my virtualenv to change to or just do $ virtualenv -p python2 ? – Shane G Dec 21 '17 at 10:52
  • 1
    You need to create a new Python 2 virtualenv. You can't convert the current Python 3 one. – Alasdair Dec 21 '17 at 10:53
  • @Alasdair Yes, you're right! I'm sorry for the confusion. I'm embarassed I haven't even known this. I have always been using just `python` for Python 2. – cezar Dec 21 '17 at 10:57
  • @cezar if you want more details, see [PEP 394](https://www.python.org/dev/peps/pep-0394/). – Alasdair Dec 21 '17 at 11:35
0

Double check whether Python2 used in this project. If so install dependencies using comment

 pip install -r requirements.txt

If Python3+ is used. Create Virtualenv with Python3 using comment

virtualenv -p python3 env

and install dependencies by

 pip3 install -r requirements.txt
Mohammed Rishad
  • 225
  • 3
  • 6