I installed the 'pandas' module and now I need to run it at my command line, but it is not available. How to make it available?
In [1]: import pandas as pd
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-af55e7023913> in <module>()
----> 1 import pandas as pd
ImportError: No module named 'pandas'
In [2]:
Your module can't be found in the current directory, in pythons site-packages folder or in any path defined in the $PYTHON_PATH environment variable.
If you installed pandas via pip install pandas and encounter an ImportError, you most likely have a problem due to multiple python distributions installed on your system.
Look carefully at the output of pip install pandas and examine the folders in its output. Find out which executable you are running when calling python via which python and look at the version numbers.
This is a very common problem btw. so prepare for a close of this question.
Related
I am using the module ydata_synthetic (github link) for generating synthetic timeseries datasets. After installing the package, I ran the following commands:
from os import path
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from ydata_synthetic.synthesizers import ModelParameters
from ydata_synthetic.preprocessing.timeseries import processed_stock
from ydata_synthetic.synthesizers.timeseries import TimeGAN
I am receiving the following error:
ImportError Traceback (most recent call last)
<ipython-input-11-9f2f25e511c0> in <module>
4 import matplotlib.pyplot as plt
5
----> 6 from ydata_synthetic.synthesizers import ModelParameters
7 from ydata_synthetic.preprocessing.timeseries import processed_stock
8 from ydata_synthetic.synthesizers.timeseries import TimeGAN
ImportError: cannot import name 'ModelParameters'
How can I solve this error?
Please make sure, that the virtual environment, where you installed the package is the same one where you try to execute your code. In case of venv or anaconda, you need to explicitly activate it in the console/terminal, then use pip to install your package and then also use that activated environment to execute your python script. If you are using an IDE, you need to set your IDE python interpreter to that specific new environment you created and installed the packe in.
Unexpected solution I found:
Use Python 3.7 (not 3.6, or 3.8+).
It seems like much of the code requires features that were new to 3.7 (eg namedtuple with default values), but the codebase has not yet been adjusted to run with python 3.8 or later.
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-c1d07d468637> in <module>
----> 1 import requests
2
ModuleNotFoundError: No module named 'requests'
I first installed a module and was wondering why it was not working.
Then I tried with modules that ought to be installed, like pandas and requests.
On all modules, I get the same issue.
Then I checked if the modules really are not installed, or if they are not in the proper folder
After that, I uninstalled and reinstalled anaconda
Nothing worked so far. I appreciate any help
Jupyter error message:
Pip installed modules:
I think you are installing your modules on a vitualenv and the Jupyter notebook is running outside the virtualenv.
This happened to me once.
Maybe you forgot to append the path to your modules to sys.path.
Example from within your notebook, if u want to import some selfwritten module from some relative location:
import sys
sys.path.append("../../../")
sys.path.append("../../")
# Rest of your code goes here, for example import $MODULE_NAME
Then you can import $MODULE_NAME (so, use the proper modulename of your desired module) iff. that module is in ../../ or in ../../../.
HTH. :-)
I'm trying to import zipline.transforms, but the output message says No module named transforms. I'm using python2.7 and downloaded zipline via conda.
from zipline.transforms import batch_transforms
ImportErrorTraceback (most recent call last)
<ipython-input-55-253f85965feb> in <module>()
----> 1 from zipline.transforms import batch_transform
ImportError: No module named transforms
First, is your IDE (pycharm or sublime) included Anaconda in the path? Second, please check where you zipline module was installed, usually .../lib/python2.7/site-packages/zipline, does it include a module called "transforms"? maybe it's an old module, not in the updated zipline anymore.
I need help with the pyodbc Python module. I installed it via Canopy package management, but when I try to import it, I get an error (no module named pyodbc). Why?
Here's the output from my Python interpreter:
import pyodbc
Traceback (most recent call last):
File "", line 1, in
import pyodbc
ImportError: No module named 'pyodbc
For the record: the attempted import was in a different Python installation. It is never good, and usually impossible, to use a package which was installed into one Python installation, in another Python installation.
I am receiving the following error in an iPython notebook:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-06ac68ebf148> in <module>()
5 import pandas as pd
6 import numpy as np
----> 7 from sklearn import neighbours
8
9 start_time = time.time()
ImportError: cannot import name neighbours
Whilst trying to run the following:
# Import required packages
import time
import pandas as pd
import numpy as np
from sklearn import neighbours
I get the same issue on the command line. My suspicions:
I believe my problem has something to do with my system path or environment variables. I've given this various attempts and have followed other answers (e.g. Python ImportError- what is wrong here?) but in vain thus far. My current system Path variable includes the location of my python script; the environment PATH variable includes the location of the Anaconda libraries: "...\Anaconda2\Library\bin;". Does this appear correct?
Many solutions refer to circular dependencies, which I do not believe I have in the one module.
Other solutions are to do with the name of the script. Mine is named 'my_solution', so I do not believe this is an issue.
My sklearn folder can be found in \AppData\Local\Continuum\Anaconda2\Lib\site-packages\sklearn
I have recently uninstalled a standalone Python application. I have also reinstalled Anadonda and the scikit-learn, numpy and scipy packages multiple times.
I am using Python 2.7.11 through Anaconda 2.5.0 on Windows 7.
You want the American spelling of neighbours, i.e.
from sklearn import neighbors