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.

gbade_
  • 339
  • 1
  • 8
  • 21

1 Answers1

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>
Community
  • 1
  • 1
Renjith Thankachan
  • 4,178
  • 1
  • 30
  • 47