Trouble setting up Dev Environments / Web Frameworks

Hi everybody, I’ve been doing lots of Codecademy courses and learning all sorts but I keep running into difficulties trying to set stuff up on my own machine…
To give two specific examples, I can’t get Django to install properly so ‘django-admin’ is not recognised at the command line. Similarly, trying set up a Rails servre, I’m missing ‘yarn’ apparently so try installing that to no avail.
I’ve managed to get ‘React’ stuff working just about.
I’ve installed Visual Studio Code, Python3, Ruby for WIndows, Node, all the stuff I need I think but keep running into these problems trying to set up my own development environment.
It may be part of the same problem… within the Ruby on Rails course, I had no trouble retrieving and displaying data but all attempts to write data were met with Authenticity Token errors.
Can anybody help me please?

A friend is telling me to abandon Windows 10 for programming stuff and switch to Ubuntu / Linux. Maybe I should… I don’t know?
‘pip install django’ didn’t work properly… or it now says requirements already satisfied but ‘django-admin’ not recognised as a command so quite lost on how to proceed. I want to do the Django course / projects off my own machine instead of having to rely on Codecademy platform.

You might want to include a little information about how this was all installed as it makes a lot of difference. Since you mention requirements already satisfied it seems likely that it has installed somewhere but is not availbable in your shell. For a particular command to be “missing” from your command line the directory containing the actual binary/script would need to be absent from your current PATH environment variable (exact name differs a little with windows vs. nix). If you’re completely unfamiliar with PATH and its purpose then spend a little time looking into it as it’s essential knowledge for actually working in a shell.

There’s a similar discussion here which is probably the same issue (installed but the command is not directly available)-

Rather than fiddling with your PATH at this point it might be easier to work with virtual environments that would typically alter your PATH for you, but only when activated.

If you’re working with pure python then the following might be useful-
https://packaging.python.org/tutorials/installing-packages/

For conda see-
https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html

Here’s a brief example of how this might be used but you’d want to nose through those links to understand a little more. Make sure to change your current working directory to something sensible if using venv (e.g. use a new project folder).

# create a new virtual environment in the folder `.venv`
python -m venv .venv

# source the environment in your current shell
. .venv/bin/activate  # for bash and simialr OR
.\.venv\Scripts\Activate.ps1 # for windows (powershell) OR
.\.venv\Scripts\Activate.bat  # for windows (cmd)

# Install django in only this environment-
python -m pip install django
# Run the command you're after-
django-admin

Conda’s route is fairly similar (see the guide).

As for Windows vs. *nix given the choice I’d use something other than windows but you can use it and tools like WSL (windows subsystem for linux) make it a little more practical.

2 Likes

Hi Tim (?), thanks so much for reply. I believe it is something do with PATH. I need to go and look at the links and documentation properly.

Re. Install… I recently bought shiny new laptop (last one died) and had to reinstall load of stuff… Python3, VS Code, Github Desktop, Postgres, Ruby (for Windows). I will confess to quite blindly ticking most boxes during installations hoping it sticks it all in the right place properly.

So yes, I need to look at your links properly and my PATH and assume my problems with trying to get Rails to work have similar cause. It doesn’t help that my HDMI connection to TV isn’t being recognised properly on new laptop (fine on the last one?) so it’s defaulting to low-res on big screen and resolution setting is greyed out for device 2 in display settings so can’t change it. Have I really got to get another telly?

Anyway, thanks again for info… I’ll report back accordingly :slight_smile:

Oh my… ‘python -m django’ has worked! Yippee. So now able to follow along with the course properly and do stuff on my own machine.

I do still, of course, need to go and look at my PATH, environment variables and other things. I’ve had trouble on quite a lot of the Back End DB related projects getting them set up on my own machine properly and all these problems are likely entwined.

Thank you again… I’m over the immediate hurdle anyway…

I am now proceeding nicely through the Django course but running into a familiar problem POSTing, PUTting…

Forbidden (403) - CSRF cookie not set

I’ve looked online and know it’s to do with my browser and CORS. I’m using Chrome, I’ve gone into all the settings and allowed cookies and stuff but not sure exactly where I tell it to allow it. I’m getting same error in Firefox.

Error mentions ‘{% csrf token %}’ but the html files provided have them where they should be.

I’m very confused by all this and had this problem on other courses too. How do I tell my browser / system to let me do what I want to do?