Pushed Django project to GitHub with Pycharm - now not working - python

Sorry for the generic question; I'm not sure how to best classify the problem.
I had a Django project that I was working on locally, then I pushed up to GitHub to collaborate with someone (I'm completely new to GitHub). I did this using pycharm and the project was copied into a subdirectory of PycharmProjects. It seemed to work fine. I didn't work on it for a week or so, during which time I upgrated to Catalina.
I've come back to work on the project and it's completely broken! I can't get the development server up and running from either the PycharmProjects directory or my original working directory on the desktop. I suspect in the PycharmProjects folder it's a path or dependency problem, but I didn't change anything in my original folder.
I can activate the virtual environment, then I get these errors:
(ll_env) Davids-MacBook-Pro-2:POM_Journal_Club davidhallsworth$ python manage.py runserver
File "manage.py", line 16
) from exc
^
SyntaxError: invalid syntax
(ll_env) Davids-MacBook-Pro-2:POM_Journal_Club davidhallsworth$ python3 manage.py runserver
Traceback (most recent call last):
File "manage.py", line 10, in main
from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 16, in main
) from exc
ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?
The repository is available at https://github.com/dchallsworth/POM_Journal_Club
Any help would be massively appreciated!! It's my first project and has taken a lot of time to learn.

Related

My Django Project now won't run Python3 manage.py runserver

So I seen this issue here on stack, but for a few slightly different reasons and I can't manage to figure it out for myself.
I'm getting this error in my terminal:
Traceback (most recent call last):
File "manage.py", line 10, in main
from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 12, in main
raise ImportError(
ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?
and YES i do have django installed.
I'm currently working on the Harvard CS50W project and it was working perfectly fine until i updated my python through HomeBrew.
Now my project can't locate django to run the server.
I seen stuff online about the virtualenv but I didn't need to set one up prior to starting this project. So I'm not sure what to do in order to get my project back up and running.
If someone could please help that would be great!
Thanks!
Also should mention I'm using the M1 Mac. Just incase that makes a difference.

Why won't the runserver command in the terminal run? I am (a complete beginner) working on building a web app (learning log) with Django

So I've already created and activated a virtual environment, created a project, and an app (but the app shouldn't really matter at this point). I'm trying to view my project and ran the server command but it won't run. To clarify, I had already made more progress with the web app: created a model and migrated it so i could use it in the app, viewed the project as an admin to see the model working but when i created the second model, i had trouble migrating it. so i took a few steps back to the point where I could just view the empty project and that also didn't work so i'm confused. I could just delete and start over but I'd like to know what's wrong at this point. Below is what the terminal shows when I tried to run 'runserver' command so I could view the project on my local server.
C:\Users\acer>cd Desktop/programming/learning_log
C:\Users\acer\Desktop\programming\learning_log>ll_env\Scripts\activate
(ll_env) C:\Users\acer\Desktop\programming\learning_log>python manage.py runserver
Traceback (most recent call last):
File "manage.py", line 10, in main
from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 12, in main
raise ImportError(
ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?
(ll_env) C:\Users\acer\Desktop\programming\learning_log>
Again, I had already managed to view the project through the admin site and even enter a topic (since I created a model for Topic) so obviously django is installed or at least was, and I did not delete any files or folders.

Ran _git rm --cached *.pyc and now No module named 'django'

I kept getting merge conflicts when trying to git pull from github to my production server and a lot of them had to do with the .pyc files.
So on my local machine, I ran
_git rm --cached *.pyc
git add .
git commit
git push -u origin dev
Since I had *.pyc in my .gitignore but hadn't committed properly.
Anyways, when I go to git pull on my production server, everything is pulled fine no merge conflicts.
But then I kept getting server errors on my site when trying to access the admin panel and this is the error
File "manage.py", line 8, in <module>
from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 14, in <module>
) from exc
ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?
Obviously I have a virtual env working and this must be because the __pycache__ files were removed with the latest commit.
Can anyone help me? I'm not sure what to do.
I was in the wrong virtalenv...I had set up the project while I was still learning so had a few virtualenvs
I have since overhauled the old project and created a new clean VPM with only one.

RabbitVCS does not work because of python error

Hello
I cannot start running rabbitvcs on openSUSE 11.3 64bit.
I tried to run test.py file which is located in rabbitvcs folder.
It returns the following errors:
jenea#linux-nguv:/usr/lib/python2.6/site-packages/rabbitvcs> python test.py
Traceback (most recent call last):
File "test.py", line 26, in <module>
import lib.helper
File "/usr/lib/python2.6/site-packages/rabbitvcs/lib/__init__.py", line 23, in <module>
from rabbitvcs.lib.log import Log
ImportError: No module named lib.log
PS: I know that is not quite programming question but it seems to me that error occurs because of some paths or settings.
Unfortunately I've no idea where to dig.
Although stupid the answer is the following:
There were two folders where rabbitvcs was intalled. The first was in /usr/lib/rabbitvcs and the second was in /usr/lib64/rabbitvcs. I'm not sure why there was described issue but after I deleted rabbitvcs folder in /usr/lib64 it started to work normally.

how do i set my python path for success with my import statements?

I'm trying to install djangobb and when running manage.py syncdb it returns with
Traceback (most recent call last):
File "manage.py", line 2, in <module>
from django.core.management import execute_manage
ImportError: No module named django.core.management
I know that deep in my python installation there is django/core/management, but I just don't know how to get manage.py to find it for me. Can someone point me in the right direction please?
Make sure that the base directory for where django/ lives is on your $PYTHONPATH

Categories