PackagesNotFoundError: The following packages are not available from current channels: - manage - python

This is my first question here. I'm new to Python, Django and Anaconda. I am trying to follow this tutorial but I keep running into hiccups. I found a similar answer to my question and I'm willing to admit that I could be misunderstanding something due to my lack of experience. I am using PyCharm and I'm installing the necessary packages (as needed for the tutorial) via the gui and I'm using the terminal inside PyCharm.
At this part of the tutorial where you're supposed to run the server of the project, I keep getting this error:
PackagesNotFoundError: The following packages are not available from current channels: - manage
Whenever I go to install from conda forge or pip install in the terminal, I am met with the same errors.
Like I said, I found a similar post on here, but it is not the solution I need. I'm also not exactly sure what I'm doing wrong. I've installed and updated python and django, and everything requested in the tutorial.
PackagesNotFoundError: The following packages are not available from current channels:
Thank you in advance for anyone who helps me.

Hey next time when you post a question add code in which you running and the whole error output in order to get the best help possible.
I am assuming running the Django application is the problem based on the information you've provided.
Try this open your terminal/command prompt and execute the following commands:
Unix
creating directory for the project
mkdir <some_directory_name>
cd <some_directory_name>
Creating python virtual env and activating it for your project.
python3 -m venv <some_env_name_of_choice>
source <some_env_name_of_choice>/bin/activate
Installing Django and creating a project.
pip3 install django
django-admin startproject <project_name_of_choice>
run Django app
cd <project_name_of_choice>
python manage.py runserver
Go to your browser and type this to verify that the app is running
http://127.0.0.1:8000
Windows
change into <some_directory_of_choice>
cd <some_directory_of_choice>
create virtual environment
python3 -m venv ./venv
activate the virtual env
source venv/bin/activate
upgrade or install pip if need be
python -m pip install --upgrade pip
run these 2 commands
python manage.py makemigrations
python manage.py migrate
run a server
python manage.py runserver
Go to your browser and type http://127.0.0.1:8000/
You might want to use python3 if running the command python gives an error. Don't forget to remove these <>
Check the official Django's site for examples on writing your first program with Django app. familiarise yourself with the basics of Django syntax etc.

Related

How can we deploy a Machine Learning Model using Flask?

I am trying, for the first time ever, to deploy a ML model, using Flask. I'm following the instructions from the link below.
https://towardsdatascience.com/deploy-a-machine-learning-model-using-flask-da580f84e60c
I created three separate and distinct .py files named 'model.py', 'server.py', and 'request.py'. I open my Anaconda Prompt end entered this: 'C:\Users\ryans>C:\Users\ryans\model.py'
Now, I get this.
I definitely have Numpy installed! Something must be wrong with my setup, or maybe the way I am starting the process is wrong, but I'm not sure what the issue is. Has anyone encountered this problem before.
I would suggest the following steps since you mentioned its your first time and when deploying a project for experimenting, it's good practice to put it in a virtual environment, which we can do with the virtualenv tool.
Assuming you already have pip installed, install virtualenv:
C:\> pip install virtualenv
Create a fresh working directory, switch to it and clone the repository from Github mentioned by the author of the article:
C:\your-working-directory\> git clone https://github.com/vyashemang/flask-salary-predictor.git
Start virtualenv in the repository's top directory
C:\your-working-directory\flask-salary-predictor\> virtualenv env
Activate the created batch file, \env\Scripts\activate.bat:
C:\Users\'Username'\venv\Scripts\activate.bat
Now in the virtual environment, install all requirements:
(env) C:\your-working-directory\flask-salary-predictor\> pip install -r requirements.txt
You can now run the model.py like you have above. I'd suggest that you run the server.py using gunicorn or on Windows use waitress according to this post so that instead of running request.py every time you want to send a request, you can use Insomnia or Postman to send API requests.

initial migrations file into virtualenv

I am trying to setup a virtual envirorment on my windows 10 laptop in cmd for a homework assignment and I'm having problems with the instructions given. I was able to get the enviroment up and running and download the requirements, but now the instructions say to Run the initial migrations with: ./manage.py migrate When I try to run the code given, I get an error saying that '.' is not recognized as an internal or external command, operable program or batch file. From the research I did the instructions that they give are for a different command language (from what I found it said Linux, but I'm preaty sure thats an operating system). I have tried looking up initial migrations with virtualenv, but I couldn't find information related to my situation. I'll post the full instructions below. Does anyone know how I can proceed?
In the root directory, where manage.py resides, do the following (all commands run from this dir)
Set up a virtual environment with virtualenv venv (virtualenv installation guide - note you may need to use sudo with the installation like sudo pip install virtualenv)
Activate virtualenv by with . venv/bin/activate
Install pip requirements by with pip install -r requirements.txt
Run the initial migrations with ./manage.py migrate
Create you own user so you can login to the admin panel with ./manage.py createsuperuser
Run the local web server with ./manage.py runserver
Check to see if it works by visiting: http://localhost:8000/admin/
Put python instead of ./
So try :
python manage.py migrate
OR
python3 manage.py migrate
OR
python3.6 manage.py migrate
The number after python is the version of python with which you installed venv.
here is my take on this question;
first make sure that the virtual env is running and you are working in a virtual enviroment then make sure all that both python and django are succesfully installed before going any further. in your root directory where jango lives, type in:
django-admin help
if you see some commands coming up then it means the django is properly installed if not then try using an editor. i prefer VS Code as it is easy to manage and user friendly and less demanding compared to others and it has an integrated terminal aswell this will solve your problem.

Should django-admin version be same as Django?

I tried to configure my PC for Django course , i have fresh Ubuntu 18.04 :
I followed all steps from the course :
I had newest python pre-installed, Python 3.6.5 so i went :
sudo apt install python3-pip
went ok, then :
pip3 install django==2.0.2 (version suggested by instructor)
that completed as well, then :
django-admin startproject wordcount
and that gave me error :
Command 'django-admin' not found, but can be installed with:
sudo apt install python-django-common
So i tried to install this but it didn't help. so i checked web for answers and i found that i should do :
sudo apt-get install python-django
And after that i could use
django-admin startproject wordcount
and it created a project for me but i saw that some elements of default files are different from what i saw on course video so i check and :
django-admin --version
1.11.11
also django-admin --help
gives me message like this :
Note that only Django core commands are listed as settings are not properly configured (error: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.).
Any ideas what went wrong and how I can fix it?
The problem is that the pip3-installed packages aren't on the PATH for some reason. There's a few ways to fix this.
Add the pip3 installation location to your $PATH.
Force it to use the version of Django you installed via pip3:
$ python3 -m django.bin.django-admin startproject wordcount
Use virtualenv or pipenv to create a "virtual" Python installation - complete with it's own Python version and set of libraries.
I see you struggle with this problem. I would recommend you to move to such thing as a virtualenv (or use anaconda for this task). This should solve a numerous other problems you've not ran across yet and this one especially.
Virtual environment allows you to create separate environment, with it's own packet set. Some IDEs (for example, pycharm) provide GUI for it's creation and management.
Update 1:
Thanks to #DhavalSavalia, of course there is also pipenv package, that is a more friendly virtualenv wrapper (unless you have some gui for virtualenv).
Update 2:
Also, I've noticed that you setting up django using apt. You probably shouldn't do that, because apt often contains old version of python packages. Use pip for as many packages as you can.

Django-admin creates wrong django version inside virtualenv

I've created a n new directory, a virtualenv and installed a django-toolbelt inside it. The django-version should be 1.8 but when I call 'django-admin.py version' it says 1.6. So when I start a new project it creates a 1.6. I thought virtualenv was supposed to prevent this. What am I doing wrong?
Edit: I think it has to do with the PATH (?). Like it's calling the wrong django-admin version. I'm on Windows 7. Still don't know how to fix it.
I came across this problem too. In the official document, I found that, in a virtual environment, if you use the command 'django-admin', it would search from PATH usually in '/usr/local/bin'(Linux) to find 'django-admin.py' which is a symlink to another version of django. This is the reason of what happened finally.
So there are two methods to solve this problem:
re-symlink your current version django-admin(site-packages/django/bin/django-admin.py) to 'usr/local/bin/django-admin' or 'usr/local/bin/django-admin.py'
REMIND: This is a kind of global way so that it will effects your other django projects, so I recommend the second method
cd to your_virtual_env/lib/python3.x/site-packages/django/bin/(of course you should activate your virtual environment), and then use 'python django-admin.py startproject project_name project_full_path' to create django project
Try and install Django into the virtual environment as well:
pip install django
It should install the latest version, you can also specify a particular version (let's say 1.8.2) if you need to:
pip install django==1.8.2
Either way you'll have the correct version of Django in your virtual environment and it should work as you expect then.
You can also use the following command to see what version you have installed:
pip show django
Update:
It seems that you have the correct version installed in your virtual environment, but for some reason your Windows 7 use the system Django installation instead while you use manage.py or django-admin.py directly. However, you can use python manage.py or python django-admin.py instead, which seems to work as expected (and use the virtualenv Django installation).
I had the same problem. Could be related to your zsh/bash settings.
I realized that using zsh (my default) I would get django-admin version 1.11 despite the Django version was 2.1! When I tried the same thing with bash I would get django-admin version 2.1 (the correct version). Certainly a misconfiguration.
So, I strongly suggest you check your zsh or bash settings to check for paths you might have.
Create a virtual environment for a project:
$ mkdir cd my_project_folder
$ cd my_project_folder
$ virtualenv venv
$ source venv/bin/activate
And now install django
(venv) ~$ pip install django==1.8
manage.py runserver in virtualenv using wrong django version
pip / virtualenv / django installation issue

Windows virtualenv not switching python for django

I managed to install virtualenv, install django-1.4-alpha-1 via pip install and am trying to start a django with it's manage.py runserver
Eventhough I switched with virtualenv via activate (note the prefix in cmd screen bellow) to the right enviroment (where I successfully installed django), manage.py runserver still somehow grabs data from my stable not-virtualenv python install.
Stable python (wrong one): D:\Python26\Scripts
Right one: E:\Prace\django-1.4-alpha-1\Scripts
My PATH doesn't include anything with Python.
Cmd screen:
Files with the .py extension are linked to your default Windows Python installation. One way of using your virtualenv python executable instead is by typing python manage.py <command> instead.
Please also see the accepted answer of a question I posted on this matter before.
You don't specify which version of virtualenv you're using. Recently, they've made --no-site-packages default, but if you're using a version before this change was instituted, you need to specify that switch to prevent the main site-packages from loading in.

Categories

Resources