Ich bin neu in Python-Web-Entwicklung. Ich benutze Django Framework, aber ich brauche auch Maschinen lernen Bibliotheken, also nach der Installation von Django und die Arbeit für eine Weile habe ich Anaconda Verteilung von Python installiert und ich habe meine Interpreter in pycharm an Anaconda geleitet. Das Problem ist, wenn ich Bibliotheken wie sklearn oder Pandas importieren und ich laufe dann Server, es gibt mir, dass Fehler in Eingabeaufforderungnicht in der Lage, Anaconda-Pakete in Django App zu verwenden
PS C:\Users\xxx\desktop\intelligent> python manage.py runserver
Performing system checks...
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x03C62780>
Traceback (most recent call last):
File "C:\Users\xxx\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django-1.10.6-py3.6.egg\django\utils\a
utoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "C:\Users\xxx\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django-1.10.6-py3.6.egg\django\core\ma
nagement\commands\runserver.py", line 121, in inner_run
self.check(display_num_errors=True)
File "C:\Users\xxx\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django-1.10.6-py3.6.egg\django\core\ma
nagement\base.py", line 374, in check
include_deployment_checks=include_deployment_checks,
File "C:\Users\xxx\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django-1.10.6-py3.6.egg\django\core\ma
nagement\base.py", line 361, in _run_checks
return checks.run_checks(**kwargs)
File "C:\Users\xxx\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django-1.10.6-py3.6.egg\django\core\ch
ecks\registry.py", line 81, in run_checks
new_errors = check(app_configs=app_configs)
File "C:\Users\xxx\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django-1.10.6-py3.6.egg\django\core\ch
ecks\urls.py", line 14, in check_url_config
return check_resolver(resolver)
File "C:\Users\xxx\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django-1.10.6-py3.6.egg\django\core\ch
ecks\urls.py", line 24, in check_resolver
for pattern in resolver.url_patterns:
File "C:\Users\xxx\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django-1.10.6-py3.6.egg\django\utils\f
unctional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\xxx\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django-1.10.6-py3.6.egg\django\urls\re
solvers.py", line 313, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\Users\xxx\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django-1.10.6-py3.6.egg\django\utils\f
unctional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\xxx\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django-1.10.6-py3.6.egg\django\urls\re
solvers.py", line 306, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Users\xxx\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 978, in _gcd_import
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
File "C:\Users\xxx\desktop\intelligent\intelligent\urls.py", line 24, in <module>
url(r'^$', include('home.urls')),
File "C:\Users\xxx\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django-1.10.6-py3.6.egg\django\conf\ur
ls\__init__.py", line 50, in include
urlconf_module = import_module(urlconf_module)
File "C:\Users\xxx\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 978, in _gcd_import
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
File "C:\Users\xxx\desktop\intelligent\home\urls.py", line 3, in <module>
from . import views
File "C:\Users\xxx\desktop\intelligent\home\views.py", line 14, in <module>
import pandas
ModuleNotFoundError: No module named 'pandas'
Meine setting.py Datei unverändert ist. Wenn ich versuche, Bibliotheken wie sklearn zu importieren, ohne django zu benutzen, dann läuft es gut, aber in der django app gibt es einen höheren Fehler, selbst wenn der Interpreter auf anaconda in pycharm eingestellt ist. Ich weiß nicht, ob view.py Datei nützlich ist oder nicht, aber hier ist es
from django.http import HttpResponse
from django.shortcuts import render
from django.template import loader
from django.shortcuts import redirect
from django.contrib.auth import authenticate,login
from django.views import generic
from django.views.generic import View
from .signupForm import UserForm
from .signinform import SignInForm
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth import logout
from django.contrib.auth.decorators import login_required
import pandas
# Create your views here.
@login_required(login_url='signin')
def index(request):
context = {'app':'app'}
return render(request,'home/index.html',context)
def signup(request):
context = {'app':'app'}
return render(request,'home/signup.html',context)
def signupform(request):
if request.method == 'POST':
form = UserForm(request.POST)
if form.is_valid():
form.save()
username = form.cleaned_data.get('username')
raw_password = form.cleaned_data.get('password1')
user = authenticate(username=username, password=raw_password)
login(request, user)
return redirect('index.html')
else:
form = UserForm()
return render(request, 'home/signup.html', {'form': form})
def signinform(request):
if request.method == 'POST':
#form = SignInForm(request.POST)
username = request.POST['username']
raw_password = request.POST['password']
user = authenticate(username=username, password=raw_password)
if user is not None:
login(request, user)
return redirect('index.html')
else:
form = SignInForm()
return render(request, 'home/signin.html')
def logoutview(request):
logout(request)
return redirect('../signin')
def diagnosis(request):
# result = main("8 1 3 100 150 1 2 77 1 1 2 2 3")
context = {'app': 'app'}
return render(request, 'home/diagnosis.html', context)
Was mache ich, wenn ich Anakonda verwenden, um mit django will? Sollte ich Django mit Anaconda-Terminal neu installieren? – Maaz