Forums

Migration Import error : cannot import name 'path'

Hi, I am new to Pythonanywhere and I am trying to deploy my sample work. So I pulled my repository from Git and now trying to run Migration . When I run it, I am getting Import Error: Cannot import name 'path' . Could anyone please help me out with this?

Hi there, do any of the tips here help? https://help.pythonanywhere.com/pages/DebuggingImportError

In my djangonautic/urls.py (which is my main project app) even after defining "from django.urls import path", the whole site page says cannot import name 'path'

I've double checked and I know the fact that django version 1.11 doesn't have "path" but I've used django version 2.0 on my local machine as well as on the pythonanywhere,

you can see it here blogbuster.pythonanywhere.com

Your site appears to be running OK now -- did you work out what the problem was?

hi, i am also facing the same issue. you can see it here sqageek.pythonanywhere.com

hmm- seems like your site is working now? Perhaps it needed a reload?

Can someone guide me I'm also facing the same issue? When I checked my bash console has python version2.7.6 and in my system console, it has 3.7.0version. what and how should I do an update. plz check and review at http://rahulbu.pythonanywhere.com/. thankq.

Which version of Django is your code written for? When I visit your site I get an error message from Django 1.11.14, but the error message is happening at a line where you have

from django.urls import path

...which I believe is what you should do in Django 2.0. If your code is for Django 2.0, then that's the version you need to install in your virtualenv.

@giles i tried to update but it seems like something gone wrong. when I ls my files stored in rahul.pythonanywhere.com(i.e., in a domain). I'm unable to understand what my actual problem is? and also I defined name path. plz look below what my bash console looks like.

12:19 ~ $ pwd
/home/rahulbu
12:54 ~ $ workon my-virtualenv
(my-virtualenv) 12:59 ~ $ pip install django
Looking in links: /usr/share/pip-wheels
Requirement already satisfied: django in ./.virtualenvs/my-virtualenv/lib/python3.6/site-packages (2.0.7)
Requirement already satisfied: pytz in ./.virtualenvs/my-virtualenv/lib/python3.6/site-packages (from django) (2018.5)
(my-virtualenv) 13:00 ~ $ ls
README.txt  rahulbu.pythonanywhere.com
(my-virtualenv) 13:08 ~ $ cd rahulbu.pythonanywhere.com/
(my-virtualenv) 13:09 ~/rahulbu.pythonanywhere.com (master)$ ls
blog  db.sqlite3  manage.py  mytestsite  rahulbu  static
(my-virtualenv) 13:10 ~/rahulbu.pythonanywhere.com (master)$ pwd
/home/rahulbu/rahulbu.pythonanywhere.com

Your website is using the virtualenv called rahulbu.pythonanywhere.com, not the one called mysite. If you start a console in that virtualenv (either by running workon rahulbu.pythonanywhere.com or by clicking the link on the "Web" page, just below where you specify the virtualenv) and then run

pip install Django>=2.0

...then that should upgrade you to a version that will work. Once you've done that, reload the website on the "Web" page.

nothing happening when i tried in virtualenv. it's waiting for another command.

(rahulbu.pythonanywhere.com) 10:16 ~/rahulbu.pythonanywhere.com (master)$ pip install Django>=2.0
(rahulbu.pythonanywhere.com) 13:40 ~/rahulbu.pythonanywhere.com (master)$ pip install Django>=2.0
(rahulbu.pythonanywhere.com) 14:01 ~ $ pip install Django>=2.0
(rahulbu.pythonanywhere.com) 14:02 ~ $

hey@giles it finally worked but by using this command

pip install --upgrade django==2.7.0

> is a redirect operator in bash. If you don't quote that, then it's not doing what you think it is. You probably have a file called =2.0 in your home directory that contains the output for pip install Django which the the command you actually ran.