There is a simple script
# -*- coding: utf-8 -*-
import xlwings as xw
import pandas as pd
wb = xw.Book('Excel_Python-1.xlsx')
data_excel = wb.sheets['Данные']
data_pd = data_excel.range('A1:C4').options(pd.DataFrame, header = 1, index = False).value
print(data_pd)
At startup error:
cannot import name 'get_running_loop' from 'asyncio'
Checked that the 'get_running_loop' method is in the events.py module from 'asyncio'.
What could be the problem?
"C:\Program Files\Python_370\python.exe" O:/___Python/__Examples/Excel/excel-1.py
Traceback (most recent call last):
File "O:/___Python/__Examples/Excel/excel-1.py", line 2, in <module>
import xlwings as xw
File "C:\Program Files\Python_370\lib\site-packages\xlwings\__init__.py", line 38, in <module>
from .udfs import xlfunc as func, xlsub as sub, xlret as ret, xlarg as arg, get_udf_module, import_udfs
File "C:\Program Files\Python_370\lib\site-packages\xlwings\udfs.py", line 4, in <module>
from asyncio import get_running_loop
ImportError: cannot import name 'get_running_loop' from 'asyncio' (C:\Program Files\Python_370\lib\asyncio\__init__.py)
I ran the script interactively. Here's the result:
C:\Windows\system32>python
Python 3.7.0a1 (v3.7.0a1:8f51bb4, Sep 19 2017, 19:32:44) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> # -*- coding: utf-8 -*-
... import xlwings as xw
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "C:\Program Files\Python_370\lib\site-packages\xlwings\__init__.py", line 38, in <module>
from .udfs import xlfunc as func, xlsub as sub, xlret as ret, xlarg as arg, get_udf_module, import_udfs
File "C:\Program Files\Python_370\lib\site-packages\xlwings\udfs.py", line 4, in <module>
from asyncio import get_running_loop
ImportError: cannot import name 'get_running_loop' from 'asyncio' (C:\Program Files\Python_370\lib\asyncio\__init__.py)
>>> import pandas as pd
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Program Files\Python_370\lib\site-packages\pandas\__init__.py", line 17, in <module>
"Unable to import required dependencies:\n" + "\n".join(missing_dependencies)
ImportError: Unable to import required dependencies:
numpy:
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.7 from "C:\Program Files\Python_370\python.exe"
* The NumPy version is: "1.20.1"
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'
>>>
>>> wb = xw.Book('Excel_Python-1.xlsx')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'xw' is not defined
>>> data_excel = wb.sheets['Данные']
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'wb' is not defined
>>> data_pd = data_excel.range('A1:C4').options(
... pd.DataFrame, header = 1, index = False).value
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'data_excel' is not defined
>>> print(data_pd)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'data_pd' is not defined
But what conclusions to draw from this - I do not know
Related
Cant set the process in Python 2.7.17 pwntools.
Source code:
from pwn import *
s=process('/root/Dokumente/Scripts/example_program')
I tried from pwn import *:
root#bitpc:~# python pwn.py
Traceback (most recent call last):
File "pwn.py", line 1, in <module>
from pwn import *
File "/root/pwn.py", line 2, in <module>
s=process('/root/Dokumente/Scripts/example_program')
NameError: name 'process' is not defined
That was not working. Then i imported process directly:
root#bitpc:~# python pwn.py
Traceback (most recent call last):
File "pwn.py", line 1, in <module>
from pwn import process
File "/root/pwn.py", line 1, in <module>
from pwn import process
ImportError: cannot import name process
I got an import error. How to fix this?
It seems that your exploit script's name is pwn.py. rename it to some other name such as exp.py. otherwise python will try to import things in your pwn.py instead of importing things from pwntools.
I have a script using openpyxl to add rows to an existing xlsx spreadsheet. It was running fine a couple of weeks ago: however, when I run it now, it starts to give me different syntax error in Python2 and Python3.
The problem I have is that the syntax error is pointing to the import packages rather than somewhere in code.
Any suggestion on how to fix these syntax issues?
Error with Python2
IDA-Data host$ python2 add_name_excel_dirs.py
Traceback (most recent call last):
File "/usr/local/Cellar/python/2.7.14/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py", line 62, in <module>
import os
File "/usr/local/Cellar/python/2.7.14/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 400, in <module>
import UserDict
File "/usr/local/Cellar/python/2.7.14/Frameworks/Python.framework/Versions/2.7/lib/python2.7/UserDict.py", line 116, in <module>
import _abcoll
File "/usr/local/Cellar/python/2.7.14/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_abcoll.py", line 662
def append(self, value: object) -> object:
^
SyntaxError: invalid syntax
Error with Python3 when running the same script:
IDA-Data host$ python3 add_name_excel_dirs.py
Traceback (most recent call last):
File "add_name_excel_dirs.py", line 5, in <module>
from openpyxl import load_workbook
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/openpyxl/__init__.py", line 26, in <module>
from openpyxl.compat.numbers import NUMPY, PANDAS
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/openpyxl/compat/__init__.py", line 5, in <module>
from .strings import (
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/openpyxl/compat/strings.py", line 9, in <module>
from .numbers import NUMERIC_TYPES
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/openpyxl/compat/numbers.py", line 28, in <module>
import pandas
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pandas/__init__.py", line 58, in <module>
from pandas.io.api import *
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pandas/io/api.py", line 10, in <module>
from pandas.io.pytables import HDFStore, get_store, read_hdf
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pandas/io/pytables.py", line 918
def append(self, key: object, value: object, format: object = None, append: object = True, columns: object = None,
^
SyntaxError: non-default argument follows default argument
I'm having a big problem with the testing framework in IntelliJ using with the python plugin.
When I launch my tests, written using unittest, the tests fail with an import error in the _jb_test_runner file.
I surfed the net for a while, but didn't get a useful solution. See the stacktrace below:
/usr/bin/python3.5 /home/davide/.IntelliJIdea2017.1/config/plugins/python/helpers/pycharm/_jb_unittest_runner.py --path /home/davide/Scrivania/musical-store/test/types/test_person.py
Testing started at 12.35 ...
Traceback (most recent call last):
File "/home/davide/.IntelliJIdea2017.1/config/plugins/python/helpers/pycharm/_jb_unittest_runner.py", line 4, in <module>
from unittest import main
File "/usr/lib/python3.5/unittest/__init__.py", line 58, in <module>
from .result import TestResult
File "/usr/lib/python3.5/unittest/result.py", line 5, in <module>
import traceback
File "/usr/lib/python3.5/traceback.py", line 5, in <module>
import linecache
File "/usr/lib/python3.5/linecache.py", line 8, in <module>
import functools
File "/usr/lib/python3.5/functools.py", line 22, in <module>
from types import MappingProxyType
ImportError: cannot import name 'MappingProxyType'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 62, in apport_excepthook
import re, traceback
File "/usr/lib/python3.5/traceback.py", line 5, in <module>
import linecache
File "/usr/lib/python3.5/linecache.py", line 8, in <module>
import functools
File "/usr/lib/python3.5/functools.py", line 22, in <module>
from types import MappingProxyType
ImportError: cannot import name 'MappingProxyType'
Original exception was:
Traceback (most recent call last):
File "/home/davide/.IntelliJIdea2017.1/config/plugins/python/helpers/pycharm/_jb_unittest_runner.py", line 4, in <module>
from unittest import main
File "/usr/lib/python3.5/unittest/__init__.py", line 58, in <module>
from .result import TestResult
File "/usr/lib/python3.5/unittest/result.py", line 5, in <module>
import traceback
File "/usr/lib/python3.5/traceback.py", line 5, in <module>
import linecache
File "/usr/lib/python3.5/linecache.py", line 8, in <module>
import functools
File "/usr/lib/python3.5/functools.py", line 22, in <module>
from types import MappingProxyType
ImportError: cannot import name 'MappingProxyType'
Process finished with exit code 1
The code does not present any syntax error, but the problem started after a refactoring of the whole project I'm working on.
Thanks in advance.
When I write the following line of code
import urllib
I get this error
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/urllib.py", line 26, in <module>
import socket
File "socket.py", line 2, in <module>
s = socket.socket()
TypeError: 'module' object is not callable
After going through various questions on SO I tried these:
from urllib import urlopen
(Same error as above)
>>> urllib
Error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'urllib' is not defined
>>> urllib.urlopen()
Error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'urllib' is not defined
Please help. I get a similar error when I try to import urllib2, urllib3, requests.
You named your file socket.py, hiding the standard library socket module. Name it something else.
I've installed Python 2.7.2 on my Windows XP computer.
I recently installed SQLAlchemy 0.7.1 using 'python setup.py install'. During the installation, I got the following error messages:
byte-compiling C:\Python27\Lib\site-packages\sqlalchemy\sql\visitors.py to visitors.pyc
SyntaxError: ('invalid syntax', ('C:\\Python27\\Lib\\site-packages\\sqlalchemy\\sql\\visitors.py', 66, 34, 'class Visitable(object, metaclass=VisitableType):\n'))
When I try to import sqlalchemy, I get the following stack trace:
>>> import sqlalchemy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\sqlalchemy\__init__.py", line 12, in <module>
from sqlalchemy.sql import (
File "C:\Python27\lib\site-packages\sqlalchemy\sql\__init__.py", line 7, in <module>
from sqlalchemy.sql.expression import (
File "C:\Python27\lib\site-packages\sqlalchemy\sql\expression.py", line 32, in <module>
from sqlalchemy import util, exc
File "C:\Python27\lib\site-packages\sqlalchemy\util\__init__.py", line 7, in <module>
from .compat import callable, cmp, reduce, defaultdict, py25_dict, \
File "C:\Python27\lib\site-packages\sqlalchemy\util\compat.py", line 93, in <module>
callable = __builtin__.callable
NameError: name '__builtin__' is not defined
Other scripts work fine and all the functions in __builtin__ seem to be available.
I can't find any examples of similar problems on Google or in the SQLAlchemy documentation.
What's wrong?
UPDATE:
Uncommenting import __builtin__ in compat.py removed the first problem. Now I seem to have problems with visitors.py:
>>> import sqlalchemy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\sqlalchemy\__init__.py", line 12, in <module>
from sqlalchemy.sql import (
File "C:\Python27\lib\site-packages\sqlalchemy\sql\__init__.py", line 7, in <module>
from sqlalchemy.sql.expression import (
File "C:\Python27\lib\site-packages\sqlalchemy\sql\expression.py", line 35, in <module>
from sqlalchemy.sql.visitors import Visitable, cloned_traverse
File "C:\Python27\lib\site-packages\sqlalchemy\sql\visitors.py", line 66
class Visitable(object, metaclass=VisitableType):
^
SyntaxError: invalid syntax
Problem partially solved: everything started working when I rolled back to SQLAlchemy 0.6.8. An issue with 0.7.1 + Windows/2.6?