I am trying to run the following code in python 3.3
from pandas import *
and I receive the following error:
Traceback (most recent call last):
File "C:\Users\Tom\Desktop\ProgrammingStuff\Python\FXCointegrationBacktesting.py", line 9, in <module>
cannot import name text_type
from pandas import *
File "C:\Python33\lib\site-packages\pandas\__init__.py", line 6, in <module>
from . import hashtable, tslib, lib
File "tslib.pyx", line 31, in init pandas.tslib (pandas\tslib.c:48782)
File "C:\Python33\lib\site-packages\dateutil\parser.py", line 24, in <module>
from six import text_type, binary_type, integer_types
ImportError: cannot import name text_type
Not sure what the problem is, I am fairly new to python and I cannot currently find any solutions to this problem on stack overflow.
Thanks!
You're using a version of dateutil that depends on six.
In dateutil <= 1.5 you don't need six, but those versions are not compatible with Python >= 3.0. So, the solution is to install six. However you do that is up to you.
You could do
pip install six
If you choose not to use pip it will depend on your system's package manager how you go about installing it.
Related
I have a simple python program which I am running on a Mac machine.
import numpy as np
def main():
print("np arr test")
arr = np.array([1.0, 2.0, 3.0])
print(arr)
if __name__ == "__main__":
main()
I've verified that the numpy library was correct installed through pip
pip3 list | grep numpy
msgpack-numpy 0.4.4.3
numpy 1.16.2
numpydoc 0.8.0
I get the following error when I run the program
Traceback (most recent call last):
File "/Volumes/brazil-pkg-cache/packages/Python-numpy/Python-numpy-1.x.140450.0/AL2012/DEV.STD.PTHREAD/build/lib/python3.6/site-packages/numpy/core/__init__.py", line 24, in <module>
from . import multiarray
File "/Volumes/brazil-pkg-cache/packages/Python-numpy/Python-numpy-1.x.140450.0/AL2012/DEV.STD.PTHREAD/build/lib/python3.6/site-packages/numpy/core/multiarray.py", line 14, in <module>
from . import overrides
File "/Volumes/brazil-pkg-cache/packages/Python-numpy/Python-numpy-1.x.140450.0/AL2012/DEV.STD.PTHREAD/build/lib/python3.6/site-packages/numpy/core/overrides.py", line 7, in <module>
from numpy.core._multiarray_umath import (
ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Volumes/workplace/RPAsosDevelopmentWS/src/RPAsosDevelopmentPy/src/rp_asos_development_py/adhoc_dev/float_nan_test.py", line 1, in <module>
import numpy as np
File "/Volumes/brazil-pkg-cache/packages/Python-numpy/Python-numpy-1.x.140450.0/AL2012/DEV.STD.PTHREAD/build/lib/python3.6/site-packages/numpy/__init__.py", line 142, in <module>
from . import core
File "/Volumes/brazil-pkg-cache/packages/Python-numpy/Python-numpy-1.x.140450.0/AL2012/DEV.STD.PTHREAD/build/lib/python3.6/site-packages/numpy/core/__init__.py", line 50, in <module>
raise ImportError(msg)
ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.6 from "/usr/local/bin/python3.6"
* The NumPy version is: "1.18.4"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: No module named 'numpy.core._multiarray_umath'
Process finished with exit code 1
Can you please help me figure out what I am missing? Appreciate your response!
NOTE : Based on the stack overflow post I updated the numpy through the following command
pip3 install numpy --upgrade
pip3 list | grep numpy
msgpack-numpy 0.4.4.3
numpy 1.21.2
numpydoc 0.8.0
WARNING: You are using pip version 21.2.1; however, version 21.2.4 is available.
However I still see the error message
Try to uninstall numpy and install it again.
I have been solving issues with my MacBook Air for the past day and I have unfortunately again bumped into some more issues. You might have seen this question before, but I couldn't solve this issue after trying all answers from
Can't use Jupyter Notebook: jsonschema apparently missing
Basically, I am now trying to enter Jupyter Notebook. I (think I) have two of them, one Jupyter Notebook installed using pip3 (Python 3.6.0), and one from Anaconda, which I uninstalled. For Anaconda, although I used anaconda clean and the rm function according to their official website and several other Stack Overflow forums, I could not uninstall the BASH and so I just left it there and installed Jupyter Notebook using pip3. But when I type Jupyter Notebook in Terminal, there is an error:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/nbformat/validator.py", line 12, in <module>
from jsonschema import ValidationError
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jsonschema/__init__.py", line 32, in <module>
from pkg_resources import get_distribution
ImportError: cannot import name 'get_distribution'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/bin/jupyter-notebook", line 6, in <module>
from notebook.notebookapp import main
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/notebook/notebookapp.py", line 83, in <module>
from .services.contents.manager import ContentsManager
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/notebook/services/contents/manager.py", line 17, in <module>
from nbformat import sign, validate as validate_nb, ValidationError
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/nbformat/__init__.py", line 33, in <module>
from .validator import validate, ValidationError
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/nbformat/validator.py", line 23, in <module>
raise ImportError(str(e) + verbose_msg)
ImportError: cannot import name 'get_distribution'
Jupyter notebook format depends on the jsonschema package:
https://pypi.python.org/pypi/jsonschema
Please install it first.
What I am using:
MacOS High Sierra 10.13.6
Macbook Air 2011 i7 4gb ram
Python 3.6.0 (pip3 to install Jupyter)
What I have installed in Python: Numpy, Pandas, Tensorflow, Keras
Thank you for helping! Please point out any errors or ways I can improve this question if possible. Also, try to answer solutions differently from Can't use Jupyter Notebook: jsonschema apparently missing .
I am getting below error when execute below:
import numpy as np
The full stack trace:
File "C:\Anaconda3\lib\site-packages\numpy\__init__.py", line 142, in <module>
from . import add_newdocs
File "C:\Anaconda3\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\Anaconda3\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
from .type_check import *
File "C:\Anaconda3\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "C:\Anaconda3\lib\site-packages\numpy\core\__init__.py", line 14, in <module>
from . import multiarray
ImportError: DLL load failed: The specified module could not be found.
Process finished with exit code 1
This looks like some of the dependencies are missing for the package numpy. The DLL load failed error points towards either incorrectly installed and/or missing files for package numpy. You should just try installing numpy again through Anaconda CLI using the following command:
conda install numpy
This works most of the times, if your python environments are sorted correctly. Do make sure that the python installation you're using for Anaconda, is the same one as your coding environment. Conflicting versions can sometimes lead to corrupted packages.
You could also try the following command to update the Anaconda Environment just to make sure that the installations are up to date, and not conflicting with older versions..
conda update -y -all
I am having issues on a new PC and cannot find an answer anywhere. I am trying to get beautifulsoup 4.4 to work on python 3.5. I am using pyCharm - I am reading that they may not be compatible but I have the same setup on my laptop and it works perfectly - only difference is the PC I am trying get BS to work on is Windows 7 where my laptop is Windows 8.
When I go into settings and look at Project Interpreter I do see BS 4.4.1 but when I try and run something I am getting this error:
Traceback (most recent call last):
File "C:/Users/PP/PycharmProjects/Shark/NOCO.py", line 3, in <module>
from bs4 import BeautifulSoup
File "C:\Users\PP\AppData\Local\Programs\Python\Python35-32\lib\site-packages\bs4\__init__.py", line 29, in <module>
from .builder import builder_registry
File "C:\Users\PP\AppData\Local\Programs\Python\Python35-32\lib\site-packages\bs4\builder\__init__.py", line 294, in <module>
from . import _htmlparser
File "C:\Users\PP\AppData\Local\Programs\Python\Python35-32\lib\site-packages\bs4\builder\_htmlparser.py", line 7, in <module>
from html.parser import (
ImportError: cannot import name 'HTMLParseError'
You are not running BeautifulSoup 4.4.1; your traceback shows you have an older version.
In 4.4.1, that section looks like this:
try:
from html.parser import HTMLParseError
except ImportError as e:
# HTMLParseError is removed in Python 3.5. Since it can never be
# thrown in 3.5, we can just define our own class as a placeholder.
class HTMLParseError(Exception):
pass
Line 7 is try:. This change was made in 4.4.0, so you have 4.3.2 or older installed instead.
Upgrade your installed package. PyCharm can do this, or you can use pip:
python3 -m pip install -U beautifulsoup4
Python 3.4
Windows 8.1
Installed modules:
matplotlib 1.3.1 for py 3.4
numpy-MLK 1.9.0b1 for py 3.4
dateutil 2.2 for py 3.4
six 1.7.3 for py 3.4
tcl
tkinter
Also msvcp71.dll is in C:\Windows\System32 (installation docs said it needed to be)
Upon running:
import matplotlib.pyplot as plt
I get the following error message:
Traceback (most recent call last):
File "<pyshell#284>", line 1, in <module>
import matplotlib.pyplot as plt
File "D:\Downloaded Programs\Python\lib\site-packages\matplotlib\pyplot.py", line 98, in <module>
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "D:\Downloaded Programs\Python\lib\site-packages\matplotlib\backends\__init__.py", line 28, in pylab_setup
globals(),locals(),[backend_name],0)
File "D:\Downloaded Programs\Python\lib\site-packages\matplotlib\backends\backend_tkagg.py", line 11, in <module>
import matplotlib.backends.tkagg as tkagg
File "D:\Downloaded Programs\Python\lib\site-packages\matplotlib\backends\tkagg.py", line 2, in <module>
from matplotlib.backends import _tkagg
ImportError: DLL load failed: The specified module could not be found.
Point being: Python\lib\site-packages\matplotlib\backends\tkagg.py is trying to
execute
from matplotlib.backends import _tkagg
but failing to do so. However _tkagg.pyd file does exist in the directory
Python\lib\site-packages\matplotlib\backends
Why is this not working then?
I know this is an old thread, but I just ran into the same problem and I found a solution, so I decided to answer it.
By taking a look at matplotlib install documentation, it says:
For Python 3.5 the Visual C++ Redistributable for Visual Studio 2015 needs to be installed.
I installed it's 64 bit version from it's Microsoft website (as I use 64 bit Python 3.6.3, and now the import works fine.
I hope it helps anyone that may face the same issue in the future.