0

I am trying to set up a Django project. Initially I had Python 3.5 installed for a data analysis project I worked on. So while Python 3.5 works in tandem with matplot, pandas, scipy etc, the Django tutorial recommended I use 2.7 for the Django project as MySQL support for Python 3.5 is only third-party. I am also required to download Microsoft Visual C++ 14.0 anytime I try pip install mysqlclient for 3.5. Unfortunately my internet connection/data is quite limited.

The thing is, I have installed 2.7 and it resides in C:\Python27. Python 3.5 is installed in C:\Users\XXXX\AppData\Local\Programs\Python\Python35-32

I have created a project directory - django-admin startproject myproject. I have installed the MySQLDb package to C:\Python27. But each time I attempt from command promptC:\Users\XXXX\Documents\WebDev\seedstars> python manage.py runserver, I get this error message:

Traceback (most recent call last):
   File "C:\Users\XXXX\AppData\Local\Programs\Python\Python35-32\lib\site-    packages\django\db\backends\mysql\base.py", line 25, in <module>
   import MySQLdb as Database
   ImportError: No module named 'MySQLdb'

I tried setting my Python interpreter in PyCharm to Python 2.7. Each time I do this - python manage.py runserver, it reverts back to the error above.

Please, how do I set this Django project to only "listen" to the Python2.7 interpreter, at cmd?

Thanks.

2
  • 3
    This is exactly what virtualenv is for. Commented Dec 12, 2016 at 13:40
  • Just hinting you to anaconda and it's awesome capabilities to register different environments to test these kind of compatability issues. Commented Dec 12, 2016 at 15:09

1 Answer 1

3

simillar question is already answered here. You can use virtualenv to isolate your project, here you can have independent python environment for dependencies & also set python version.

Check extenal site here for more detailed tutorial.Using virtualenv you can create this setup using the below command.

virtualenv <virtualenv name> -p <path to version specific python>
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.