Issue encountered: "Python unable to find module named http_client while attempting to execute Django alongside Django Rest Framework."

My goal is to develop a basic API using the django rest framework. The code in my view looks like this:

    from django.shortcuts import render
from moviestash.models import Movie
from moviestash.serializer import MovieSerializer
from rest_framework import generics

#List all movies and add movies
class MovieList(generics.ListCreateAPIView):
    queryset = Movie.objects.all()
    serializer_class = MovieSerializer

#Get a movie and delete a movie
class MovieDetail(generics.RetrieveDestroyAPIView):
    queryset = Movie.objects.all()
    serializer_class = MovieSerializer

However, whenever I try to access any URL while running the server, I encounter the following error message:

Request Method: GET
Request URL: http://127.0.0.1:8000/

Django Version: 1.6
Python Version: 2.7.0
Installed Applications:
('django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'moviestash',
 'south',
 'rest_framework')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware')

Traceback:
File "N:\Python\venvs\rest_api\lib\site-packages\django\core\handlers\base.py" in get_response
  101.                 resolver_match = resolver.resolve(request.path_info)
...
Exception Type: ImportError at /
Exception Value: No module named http_client

In trying to troubleshoot the issue, I found that when importing `http_client` from `django.utils.six.moves`, there seems to be an issue with the `responses` object. While I am able to import `http_client` successfully in the django shell, attempting to import `responses` using `from django.utils.six.moves.http_client import responses` results in an ImportError.

Answer №1

It seems like you've encountered problem 2969. To resolve this, consider updating your Django version from 1.6 to 1.6.11. However, keep in mind that Django 1.6 has reached its end of life and no longer receives security patches. It's recommended to upgrade to the latest supported Django version or the newest LTS release.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Addition in numpy can be thought of as operating in a matrix

In my numpy code, I have a row vector represented as a and a column vector represented as b. If I were to perform matrix multiplication on these vectors, the resulting matrix m would have values calculated using the formula m[i,j] = a[i]*b[j]. Now, I am ...

What could be causing my write() function to output an empty text file instead of the expected content? - web scraping issue

I am encountering an issue where my code is generating a blank text file instead of populating it with the expected items. When I run the script in Anaconda, the text is successfully printed inside the file which leads me to believe that the problem lies w ...

Forwarding to another page following an AJAX post request to a Django view

I've been struggling to get this basic piece of code to work properly, despite trying numerous resources. I can't seem to pinpoint where I'm going wrong. Essentially, I have a javascript function submitData() that is supposed to make an ajax ...

Uh oh! The site you are trying to access at /admin/login does not exist. Please try again or contact the admin for assistance

After completing Corey's blogging YouTube series and Mitchell's ecommerce Udemy course, I attempted to combine the two by integrating mapping functionality. This required me to switch the production database I was using, which may have caused som ...

Python class initialization for computing cumulative style metrics from data table entries

I am currently working on finding the optimal value of Z within a data table using Python. The ideal Z value is determined when there is a difference of more than 10 in Y values. As part of my code implementation, I am categorizing each entry into a specif ...

Transforming data in Pandas by consolidating multiple columns into a single column

I have some data that needs to be reshaped to better organize the results. The data consists of initial columns followed by a varying number of columns grouping the data. Each group is marked with an 'x' if the key belongs to it, with keys potent ...

Retrieve a particular value from a JSON object

I'm currently working with a json file that has a specific structure. It includes an 'edition' and various 'attributes' with trait types and corresponding values. For instance, 'Background': 'Gray', 'Base&a ...

How to retrieve data as a dictionary instead of a tuple using MySQL's fetchall() method

I have a table with the columns id, col1, col2, and col3. When I ran the query, this is how it was executed: cur.execute(query) row = cur.fetchall() Is there a way to store the data in the variable row inside a dictionary so that I can pass this result t ...

Prevent Symfony2 Twig from rendering HTML content

Is there a way to disable the rendering of HTML responses in Twig? I am currently working on a RESTful API and my goal is to completely prevent HTML rendering. For instance, if I access /foo/bar without an oAuth Access Token, Symfony2 should reply with a ...

Encountered an OverflowError when attempting to solve the problem of calculating the total number of subsets without consecutive numbers

I'm currently working on solving a challenge in TalentBuddy using Python Here is the problem statement: Given an integer N, you need to find the total number of subsets that can be created using the set {1,2..N}, ensuring that none of the subsets ...

``"Issue: 'remap' function is not recognized within the 'cv' module"`` occurring during the execution of the command "python setup.py install

Currently attempting to set up a face tracking system for Python on Ubuntu using the terminal. I installed the necessary files from the following links: https://pypi.python.org/pypi/pyFaceTracker/0.1.1 The setup.py version for Linux can be found here: D ...

How to combine data frames using multiple intervals

Looking for a solution similar to this question: Fastest way to merge pandas dataframe on ranges However, I have multiple ranges to take into account during the merging process. I possess a dataframe labeled A: ip_address server_port 0 13 ...

Transform a dictionary of bytes into JSON format

I've encountered an issue trying to convert a bytes dictionary returned from an API into JSON format, but so far I haven't been successful. Here is a snippet of the sample data: >>> endpoint_req.content b'{\n "ERSEndPoint" : ...

Exploring Feature Extraction and Dimension Reduction with MLP

I am currently developing a model that utilizes MLP for both feature extraction and dimension reduction. This model has the ability to condense data from 204 dimensions down to just 80 dimensions through the following process: A dense layer with 512 dimen ...

XMLHttpRequest Error: The elusive 404 code appears despite the existence of the file

This is the organization of my project files: The folders Voice, Text, and Template are included. https://i.stack.imgur.com/9un9X.png When I execute python app.py and navigate to localhost http://0.0.0.0:8080/, the index.html page is displayed with conte ...

I am having trouble finding the tabFrame frame shown in the screenshot below

https://i.stack.imgur.com/wCJhN.png I'm having trouble finding the frame labeled tabFrame in the screenshot provided. I did manage to locate outlookFrame successfully. This is the code I used: driver.switch_to.frame('outlookFrame') However ...

Playing TIC TAC TOE with a fun twist of skipping turns

I've been tackling a python tic-tac-toe program lately. Everything seems to be working smoothly for the Human player's turn, but once the AI takes its first turn, it stops making any further moves. I've carefully gone through the code multip ...

A guide on linking an object in strapi V4 to a React app

Recently in strapi v4, there was a change in the response API structure from an array to an object. When analyzing the response using Postman on my local strapi API and converting it into raw format with stringify, I noticed that the API response consists ...

Tweepy in Python experiencing intermittent errors while streaming

I have implemented this code to extract the content from live streams using the 'text' identifier to capture tweet texts. Although it is mostly functioning well, occasionally I encounter a "Not Working" message due to an exception in the code whe ...

Transforming a Microsoft SQL Server varbinary into a base64 encoded string

The objective I need to retrieve an image from a mssql database, convert it to base64 format, and then embed it in an email. Specifics The image is stored as varbinary data in the mssql database. 0xFFD8FFE00.... Upon querying this image in an outdated J ...