-1

New to PyCharm and Django, I've looked through online for this solution for a few hours already, nothing seems to work.

The usual: python -m django-admin startproject mysite does not seem to work if my cmd directory is at C:\Users\...\PycharmProjects\

On the other hand, if I use cd C:\Users\...\AppData\Local\Programs\Python\Python38\Scripts before reentering the former code, I get the exact results that I want.

Any idea how to fix this?

Edit: Okay, so I figured a solution. If I were to copy "django-admin.exe" into C:\Users\...\PycharmProjects\, django-admin startproject mysite will work as intended.

The real issue I have is the command python -m itself. Nothing that follows after that line seems to work with it. I've revised my advanced environment pathing, but so far I haven't had much luck.

Edit 2: Typing python takes me to Windows Store, but py will work as intended. Subsequently, problems like py -m django --version will work as intended if I type them in cmd. However, the problem persist if I try to do it in my PyCharm virtual environment.

I've tested and changed multiple directories for both cmd and PyCharm's virtual environment, the solution works consistently in cmd, but not in Pycharm. Any explanations for this?

David LE
  • 95
  • 11

1 Answers1

0

You have to add python to your system path variable this is a quick tutorial on how to do so

RaoufM
  • 525
  • 5
  • 22
  • I followed exactly the instructions of the link that you've gave me, but the problem is still not resolved. – David LE Jun 23 '20 at 15:03
  • Try to run `django-admin startproject mysite` without `python -m` – RaoufM Jun 23 '20 at 15:10
  • Didn't work either. For some reason my `python -m` command is really screwed. `pip show django` works fine in cmd, but `python -m django --version` doesn't. – David LE Jun 23 '20 at 15:17
  • Can you open the python shell in cmd ? By simply typing python – RaoufM Jun 23 '20 at 15:27
  • Typing `python` as itself takes me directly to microsoft store. No response if I typed `python -`. I've edit my question above a little. Thanks for staying with me for so long. – David LE Jun 23 '20 at 15:36
  • Your path variable should point to where python is installed .. since runing python by itself doesnt work that means it is a path variable problem because you can not run python outside of the installation folder – RaoufM Jun 23 '20 at 15:45
  • This is getting more and more confusing. `python` takes me to windows store, but `py` would work as intended. Consistent with this page https://stackoverflow.com/questions/58754860/cmd-opens-window-store-when-i-type-python Now if I were to run `py -m django --version` in cmd, it will also work as intended, but if I try running that in PyCharm's virtual environment, it stops working. – David LE Jun 23 '20 at 15:56
  • I'm sorry i dont use pycharm as my ide so i dont know much about it – RaoufM Jun 23 '20 at 16:28