Difficulty Importing "sympy" - sympy

I am trying to import sympy in Spyder 5.2.2 using:
'from sympy import *'
This worked a couple of days ago, but now I am getting an error on the import:
"name 'init_printing' is not defined"
Does anyone else have this issue or know of a solution?

I had this issue and importing it as something worked out.
You can try:
import sympy as sp
from sympy import init_printing
init_printing()
from sympy import init_session

Related

I am trying to import gensim, pandas and numpy in my django project but getting import error

I am getting an import error as i try to import gensim, pandas and numpy in django views.py . It works fine in shell.
How can I import them in views.py. I have installed the libraries in virtual environment.

Python: i cant do substitution

I'm using python2.7
I ran this code
print r.data
print r[0][action-1].data
then it throws this.
[[ 0.34642464 0.39359313 -1.24270797 -0.89923799 0.11451679 -0.49929592]]
-0.499295920134
then, i tried to substitution "r" like this
r[0][action-1].data = 1
but i couldn't.
print r[0][action-1].data
-0.499295920134
what's my problem?
i imported this.
import numpy as np        
import matplotlib.pyplot as plt
import cv2
import random
import chainer
from chainer import cuda
from chainer import serializers
import chainer.functions as F
from chainer import optimizers
print(type(r)) is
class 'chainer.variable.Variable'
print (type(r[0])
is also
class 'chainer.variable.Variable'
  

Python 2.7.5 getting import OrderedDict ImportError: No module named OrderedDict

import OrderedDict
ImportError: No module named OrderedDict
i'm using python 2.7.5 and assume orderedDict module to be pre-installed.
How can i check if the module is present and if not how can i install it.
I'm beginner and thanks for helping me out.
OrderedDict belongs to the collections module. It is not standalone.
You need to from collections import OrderedDict.
Expanding what JoshuaRLi said, you want
>>> from collections import OrderedDict
You can check which modules you have available with
>>> help('modules')
This question came up when I was trying to find a solution to a similar issue, so I post this here for anyone else that has this problem.
I received this error when trying to import gstools:
import gstools as gs
Notice that part of the error says:
if sys.version_info < (3, 9):
from typing_extensions import OrderedDict
else:
from collections import OrderedDict
So updating to python 3.9 or greater imported from collections instead of typing_extensions, fixing my problem.

django on jython(cannot import name BaseDatabaseWrapper)

I have a problem buliding django on jython
I have already installed django-jython , jython , django
in settings.py dababase engine I write : doj.db.backends.sqlite
raiseImproperlyConfigured(error_msg)
django.core.exceptions.ImproperlyConfigured:
'doj.db.backends.sqlite' isn't an
available database backend.
Try using 'django.db.backends.XXX', where XXX is one of:
u'base', u'mysql', u'oracle', u'postgresql_psycopg2', u'sqlite3'
Error was: cannot import name BaseDatabaseWrapper
it seems that in doj.db there is no these classes which I can find in django.db
and I find in site-packages\django_jython-1.7.0b2-py2.7.egg\doj\db\backends\sqlite\base.py
there are :
from doj.db.backends import JDBCBaseDatabaseWrapper as BaseDatabaseWrapper
from doj.db.backends import JDBCBaseDatabaseFeatures as BaseDatabaseFeatures
from doj.db.backends import JDBCBaseDatabaseOperations as BaseDatabaseOperations
from doj.db.backends import JDBCCursorWrapper as CursorWrapper
from doj.db.backends import JDBCConnection
maybe the problem lies here
thanks for your help
I got the same problem. It's Django compatibility issue indeed. django-jython 1.7 works with Django 1.7.x (see https://pythonhosted.org/django-jython/release-notes.html#b2)

django import module with a system name

I would like to import a function from the views.py file of my import module.
The following code does not work: from import.views import myFunction. How to do?
**
Edit:
** So far I was able to import other files from the import module:
sys.path.append(settings.SITE_ROOT+'import')
import myFile as test
It doesn't seem to work for the view though, don't know why!