0
votes

I followed djangogirls tutorial to get started with django and had everything working. Once I finished the basic tutorial, everything in working order, I decided to go through the steps again to make something new and become more familiar with using git, django, venv, etc.

fyi - I am on windows 10 and have python 2.7 and python 3.5 installed. I am using python 3.5.2 with django 1.10.4.

steps:

>mkdir v2
>cd v2
>"d:/python 3.5.2/python" -m venv myenv
>cd myenv/scripts/activate
(myenv) python -m pip install -U pip

for some reason this is the only way I was able to upgrade pip this time around

(myenv) d:/v2/myenv/scripts> pip install django~=1.10.0
(myenv) d:/v2/myenv/scripts> django-admin.py startproject mysite

This is where the magic doesn't happen:

d:\v2>django-admin.py startproject mysite2
Traceback (most recent call last):
  File "D:\v3\myenv\Scripts\django-admin.py", line 2, in <module>
    from django.core import management
  File "C:\Python27\lib\site-packages\django\core\management\__init__.py",         line 10, in <module>
    from django.apps import apps
  File "C:\Python27\lib\site-packages\django\apps\__init__.py", line 1, in     <module>
    from .config import AppConfig
  File "C:\Python27\lib\site-packages\django\apps\config.py", line 4, in     <module>
    from django.core.exceptions import AppRegistryNotReady,     ImproperlyConfigured
  File "C:\Python27\lib\site-packages\django\core\exceptions.py", line 5, in <module>
    from django.utils.encoding import force_text
  File "C:\Python27\lib\site-packages\django\utils\encoding.py", line 11, in <module>
    from django.utils.six.moves.urllib.parse import quote, unquote
  File "C:\Python27\lib\site-packages\django\utils\six.py", line 92, in     __get__
    result = self._resolve()
  File "C:\Python27\lib\site-packages\django\utils\six.py", line 160, in     _resolve
    module = _import_module(self.mod)
  File "C:\Python27\lib\site-packages\django\utils\six.py", line 82, in     _import_module
    __import__(name)
  File "C:\Python27\lib\urllib.py", line 26, in <module>
    import socket
  File "C:\Python27\lib\socket.py", line 47, in <module>
    import _socket
ImportError: Module use of python35.dll conflicts with this version of Python.

As far as I am aware, I followed the same steps. I am not sure why the djano installed in my venv would be referencing python 2.7, since I thought if created my venv from the python 3.5.2 dir it would reference that version, along with anything I used pip for within that dir?

Can someone help me find what I am missing here? ty.

2

2 Answers

0
votes

By default virtualenv uses python2. If you want to use python3, you have to specify it explicitly.

Run following command to setup virtualenv with python3: virtualenv -p python3 envname

0
votes

While in "Python 3.5.2/scripts" I ran:

virtualenv d:/<dirname>

Everything after(django-admin.py startproject projectname) worked correctly. Still not sure what went wrong here but maybe this helps someone else...