Error running script python - python

Traceback (most recent call last):
File "C:\Users\flemos\AppData\Local\Programs\Python\Python35-32\lib\pandas\__init__.py", line 7, in <module>
from pandas import hashtable, tslib, lib
ImportError: DLL load failed: %1 is not a valid Win32 application.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\flemos\Desktop\OptimalRoadTripHtmlSaveAndDisplay.py", line 10, in <module>
import pandas as pd
File "C:\Users\flemos\AppData\Local\Programs\Python\Python35-32\lib\pandas\__init__.py", line 13, in <module>
"extensions first.".format(module))
ImportError: C extension: DLL load failed: %1 is not a valid Win32 application. not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace' to build the C extensions first.

Check if you are using the same version of python as your library i.e. both 64bit or both 32bit.

Related

python importing psycopg2 error: ImportError: DLL load failed while importing _psycopg: the specified module could not be found

I am trying to import the library psycopg2 but I get this error:
Traceback (most recent call last):
File "c:\Users\me\OneDrive\Desktop\pythonProject\fromSMStoDB\app.py", line 2, in
import psycopg2
File "C:\Users\me\AppData\Local\Programs\Python\Python310\lib\site-packages\psycopg2_init_.py", line 51, in
from psycopg2._psycopg import ( # noqa
ImportError: DLL load failed while importing _psycopg: the specified module could not be found.
I am using python version: 3.10.0 and as editor, I am using VS code.

Issue running python script via PyCharm but not Anaconda Prompt

When I run a script in Anaconda Prompt, it works fine.
When I try to run it via PyCharm, I get this error related to the import of pandas.
C:\ProgramData\Anaconda3\python.exe C:/Users/MYUSERNAME/PycharmProjects/CARA/DocumentAccessCheck.py
Traceback (most recent call last):
File "C:/Users/MYUSERNAME/PycharmProjects/CARA/DocumentAccessCheck.py", line 2, in <module>
import pandas as pd
File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\__init__.py", line 19, in <module>
"Missing required dependencies {0}".format(missing_dependencies))
ImportError: Missing required dependencies ['numpy']
Process finished with exit code 1
If I try to import numpy and run it via PyCharm I get:
C:\ProgramData\Anaconda3\python.exe C:/Users/MYUSERNAME/PycharmProjects/CARA/DocumentAccessCheck.py
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\core\__init__.py", line 16, in <module>
from . import multiarray
ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/MYUSERNAME/PycharmProjects/CARA/DocumentAccessCheck.py", line 2, in <module>
import numpy as np
File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\__init__.py", line 142, in <module>
from . import add_newdocs
File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
from .type_check import *
File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\core\__init__.py", line 26, in <module>
raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control). Otherwise reinstall numpy.
Original error was: DLL load failed: The specified module could not be found.
Process finished with exit code 1
Running the same script in Anaconda prompt...no problem
My run configuration in PyCharm uses the Anaconda python distribution?
It should be noted that I am not using envirnoments, just the base Anaconda installation. More worryingly I dont see ANY Conda options in the project settings in PyCharm which a lot of tutorials seem to allude to.
Seems like a problem with the path for your scripts. Are you sure You have included your scripts in the PATH variable? If so are you sure your libraries are downloading/installing in that path?

Running python 3 on 64bit, packages updated; ImportError: DLL load failed: %1 is not a valid Win32 application

Traceback (most recent call last):
File "C:\Python27\Lib\site-packages\numpy\core\__init__.py", line 16, in <module>
from . import multiarray
ImportError: DLL load failed: %1 is not a valid Win32 application.
This is the error I receive. I have updated my packages and am running on a x64 system. Any reason why I have this issue?

error Installing pymqi on 64bit windows machine

After struggling a lot to build pymqi ,i finally built it. but now when i import the pymqi library its throwing an error message :
>>> import pymqi
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "pymqi\__init__.py", line 109, in <module>
import pymqe, CMQC, CMQCFC, CMQXC
ImportError: DLL load failed: %1 is not a valid Win32 application.
In case some one wants the build log :
https://codetidy.com/8314/

Import Error: C extension (pandas; python; ubuntu)

I am new to Linux and do not know how to fix this error.
$ python googledrive/scripts/test.py
Traceback (most recent call last):
File "/home/michael/anaconda3/lib/python3.5/site-packages/pandas/compat/__init__.py", line 46, in <module>
import __builtin__ as builtins
ImportError: No module named '__builtin__'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/michael/anaconda3/lib/python3.5/site-packages/pandas/__init__.py", line 7, in <module>
from pandas import hashtable, tslib, lib
File "pandas/tslib.pyx", line 53, in init pandas.tslib (pandas/tslib.c:102872)
File "/home/michael/anaconda3/lib/python3.5/site-packages/pandas/compat/__init__.py", line 59, in <module>
import http.client as httplib
File "/home/michael/anaconda3/lib/python3.5/http/client.py", line 71, in <module>
import email.parser
File "/home/michael/googledrive/scripts/email.py", line 4, in <module>
import pandas.io.data as web
File "/home/michael/anaconda3/lib/python3.5/site-packages/pandas/io/data.py", line 15, in <module>
from pandas.compat import(
ImportError: cannot import name 'bytes_to_str'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "googledrive/scripts/test.py", line 11, in <module>
main()
File "googledrive/scripts/test.py", line 2, in main
import pandas as pd
File "/home/michael/anaconda3/lib/python3.5/site-packages/pandas/__init__.py", line 13, in <module>
"extensions first.".format(module))
ImportError: C extension: 'bytes_to_str' not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace' to build the C extensions first.
Python 3.5.0 :: Anaconda 2.4.0 (64-bit)
I tried conda install -f pandas and it still hasn't fixed my issued.
googledrive/scripts/test.py
def main():
import pandas as pd
import pandas.io.data as web
all_data = {}
all_data['fb'] = web.DataReader('fb','yahoo','1/1/2015', '11/24/2015')
print(all_data['fb'])
I do not know which directory I should run the below suggestion.
python setup.py build_ext --inplace
I don't have any problem running the code line by line in the terminal, but only when I try to run my script file.
>>> print(all_data['fb'])
Open High Low Close Volume \
Date
2015-01-02 78.580002 78.930000 77.699997 78.449997 18177500
2015-01-05 77.980003 79.250000 76.860001 77.190002 26452200
2015-01-06 77.230003 77.589996 75.360001 76.150002 27399300
Any help would be greatly appreciated.

Categories

Resources