I installed python today and used pip install successfully to get some modules. But I am unable to import any .py modules.
I created mod.py (it has a simple print command) in the same directory as the code I am trying to run. I uninstalled and reinstalled anaconda as well. But the error persists. Anyone with any ideas on how to fix this? Thanks!
import mod
NameErrorTraceback (most recent call last)
<ipython-input-1-18de99490651> in <module>()
----> 1 import mod
C:\Users\Mayank\mod.py in <module>()
3 {
4 "cell_type": "code",
----> 5 "execution_count": null,
6 "metadata": {},
7 "outputs": [],
NameError: name 'null' is not defined
This is a sample of what the .py code looks like in the editor (same problem):
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def fib(n): # write Fibonacci series up to n\n",
" a, b = 0, 1\n",
" while b < n:\n",
" print b,\n",
" a, b = b, a+b\n",
"\n",
"def fib2(n): # return Fibonacci series up to n\n",
" result = []\n",
" a, b = 0, 1\n",
" while b < n:\n",
" result.append(b)\n",
" a, b = b, a+b\n",
" return result"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.15"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
null
isn't a reserved word like it is in JavaScript. None
is used.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With