Trying to run pyexiv2 - python

I'm trying to run a simple code to test that I have installed correctly pyexiv2 in my computer. I'm using python 2.6.6. on windows 7 64 bit
So I run this simple code:
import pyexiv2
print pyexiv2.exiv2_version_info
and I get this error:
Traceback (most recent call last):
File "C:/Users/Usuario/Desktop/pyexiv2/pyexiv2.py", line 1, in <module>
import pyexiv2
File "C:\Users\Usuario\Desktop\pyexiv2\pyexiv2.py", line 3, in <module>
print pyexiv2.version_info
AttributeError: 'module' object has no attribute 'version_info'
How can I fix that? Thank you

You named your own file pyexiv2.py as well; rename it or delete it, as it is being imported instead of the installed module.

Related

run capital-gains command and get erro: AttributeError: module 'argparse' has no attribute 'BooleanOptionalAction'

I'm trying to use python library capital-gains
I refer https://pypi.org/project/capital-gains/ this python docs.
when I run capital-gains command it throws an error:
AttributeError: module 'argparse' has no attribute
'BooleanOptionalAction'
Traceback (most recent call last): File
"/home/archana/mantralabs/backend/env/bin/capital-gains", line 8, in
sys.exit(main()) File "/home/archana/mantralabs/backend/env/lib/python3.6/site-packages/capital_gains/capital_gains.py",
line 11, in main
parser = argument_parser.get_parser() File "/home/archana/mantralabs/backend/env/lib/python3.6/site-packages/capital_gains/argument_parser.py",
line 52, in get_parser
action=argparse.BooleanOptionalAction, AttributeError: module 'argparse' has no attribute 'BooleanOptionalAction'
Python version - 3.8
Can anyone help me? i'm not able to find out solution on google
Actually The argparse.BooleanOptionalAction feature is only available in Python 3.9 and above.
you can try with python 3.9 or above version's

AttributeError: module 'importlib' has no attribute 'util' II

I have a problem very similar to this one but I'm not about using gcloud but I'm trying to run pyqtdeploy.
I'm facing a strange problem: Running
>>> import importlib
>>> importlib.util.spec_from_file_location()
gives me
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'importlib' has no attribute 'util'
..using Python3.8.6 with importlib-1.0.4 running on a Debian 10 +testing machine
while the exact same commands on Fedora 32 also running Python3.8.6 with importlib-1.0.4 let me use importlib.util:
>>> importlib.util.spec_from_file_location()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: spec_from_file_location() missing 1 required positional argument: 'name'
Why can the exact same module have an attribute on one system and not on the other?
And how do I make pyqtdeploy (and thus importlib.util) work as expected?
Background: I'm currently trying to run pyqtdeploy inside a Docker container but despite I'm using the same versions of Python and importlib it will run on the Fedora host but not inside the container..
user2357112 offers sound advice:
from importlib import util
Use instead e.g. from importlib import util as iutil and then iutil.spec_from_file_location().

Unable to import pandas module; python prints AttributeError from older python session

I have a weird issue. Whenever I import pandas, I get an AttributeError:
import pandas as pd
AttributeError: 'module' object has no attribute 'read_sql_query'
That error message is from an old python session when I was playing around with pandas. I'm now unable to load pandas as all, I just get that attribute error. Here's the full stacktrace:
>>> import pandas as pd
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/tsd/p19/home/p19-jonasmst/.local/lib/python2.7/site-packages/pandas/__init__.py", line 13, in <module>
__import__(dependency)
File "/cluster/software/VERSIONS/python_packages-2.7_3/cluster/software/VERSIONS/python2-2.7.9/lib/python2.7/site-packages/pytz/__init__.py", line 29, in <module>
from pkg_resources import resource_stream
File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 74, in <module>
File "parser.py", line 12, in <module>
asid_occurrences = pd.read_sql_query(sql_find_asid_occurrences, db)
AttributeError: 'module' object has no attribute 'read_sql_query'
Possibly relevant info:
I'm on a cluster and have to load python2 as a module in order to import pandas.
I'm logged in to a Linux VM on the cluster through a Thinlinc client (via FireFox), from which I'm again SSHed into another Linux VM.
I've tried module purge and then module load python2 again, to no avail.
I've tried to log out from the VM and back in again, to no avail.
I was using VIM when I first got the AttributeError.
Anyone have any idea what's going on here? Thanks!
Update:
This seems to happen only when I'm in the directory where I got the error earlier. Moving to another directory allows me to import pandas just fine. There are no hidden files or anything in that directory, though, so I don't understand what's going on here.
The problem was that my script was called parser.py which probably conflicts with something in pandas. Similar issue.

Python 2.7 & emulambda

Just installed emulambda today, using the command:
pip install git+https://github.com/fugue/emulambda.git
and created a simple python file test.py:
from __future__ import print_function
def lambda_handler(event, context):
print("Hello world")
when I try and run this with the command
emulambda test.lambda_handler test-event.json
I get the errors
Oops! There was a problem finding your function.
Traceback (most recent call last):
File "/usr/local/bin/emulambda", line 5, in <module>
emulambda.main()
File "/usr/local/lib/python2.7/dist-packages/emulambda/__init__.py", line 37, in main
lfunc = import_lambda(args.lambdapath)
File "/usr/local/lib/python2.7/dist-packages/emulambda/__init__.py", line 121, in import_lambda
raise e
AttributeError: 'module' object has no attribute 'lambda_handler'
I'm running python 2.7.12 - can anyone suggest what the problem is?
You called your module test.py, which is a conflict with the internal Python regression test module when you attempt to do the following:
emulambda test.lambda_handler test-event.json
Rename your file to something else like simon_test.py and try it again with:
emulambda simon_test.lambda_handler test-event.json

ImportError: cannot import name pynestkernel

So I spend last night trying to install nest (and pynest) to use with PyNN, and I am currently stuck. When I try to import nest I get:
>>> import nest
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/nest/__init__.py", line 52, in <module>
from . import pynestkernel as _kernel
ImportError: cannot import name pynestkernel
However, when I make the make installcheck it passes all the pynest tests.
I am using OS x Yosemite, and I did a new install of python 2.7.9 using macport.
Tried:
easy_install python-nest
Now I am getting a new error.
Getting:
>>> import pyNN.nest as sim
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import pyNN.nest as sim
File "/Library/Python/2.7/site-packages/pyNN/nest/__init__.py", line 13, in <module>
from pyNN.nest import simulator
File "/Library/Python/2.7/site-packages/pyNN/nest/simulator.py", line 500, in <module>
state = _State() # a Singleton, so only a single instance ever exists
File "/Library/Python/2.7/site-packages/pyNN/nest/simulator.py", line 60, in __init__
self._cache_num_processes = nest.GetKernelStatus()['num_processes'] # avoids blocking if only some nodes call num_processes
AttributeError: 'module' object has no attribute 'GetKernelStatus'
Try using setuptools to install nest with easy_install python-nest.
I am trying something similar, with the further goal of having it working with python 3. So far I used the following commands:
git clone https://github.com/nest/nest-simulator.git
cd nest-simulator
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr/local/nest -DPYTHON_EXECUTABLE=/usr/local/bin/python3 -DPYTHON_INCLUDE_DIR=/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/include/python3.5m -DPYTHON_LIBRARY=/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/libpython3.5.dylib .
make
make install
which runs without errors and I can happily run nest. Iam still having troubles running pyNN (see https://laurentperrinet.github.io/sciblog/posts/2016-06-01-compiling-and-using-pynn-%2B-nest-%2B-python3.html)

Categories