Python Lifetimes Module Error - python

I was trying to load the Lifetimes Module on my Linux AMI server.
I installed it just fine and everything seemed to work with no error.
However when I went to use it I got the error below. (tried to do a few things that I thought would fix it but nothing has worked)
import lifetimes
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "lifetimes/__init__.py", line 1, in <module>
from .estimation import BetaGeoFitter, ParetoNBDFitter, GammaGammaFitter
File "lifetimes/estimation.py", line 2, in <module>
from collections import OrderedDict
ImportError: cannot import name OrderedDict

http://linuxconfig.org/how-to-change-from-default-to-alternative-python-version-on-debian-linux
This is what worked for me but I did have to re-install the modules that were on 2.6 into 2.7

Related

Traceback ImageAi

Good afternoon, For the second day I can't move forward because of this problem. I've been doing python recently. I downloaded all packages, checked with the versions I have python 3.10. And it gives this error every time. Tell me what to do, please.
D:\pythonProject\venv\Scripts\python.exe D:\pythonProject\main.py
Traceback (most recent call last):
File "D:\pythonProject\main.py", line 1, in <module>
from imageai.Detection import ObjectDetection
File "D:\pythonProject\venv\lib\site-packages\imageai\Detection\__init__.py", line 2, in <module>
from imageai.Detection.keras_retinanet.models.resnet import resnet50_retinanet
File "D:\pythonProject\venv\lib\site-packages\imageai\Detection\keras_retinanet\models\resnet.py", line 19, in <module>
import keras
ModuleNotFoundError: No module named 'keras'
Process finished with exit code 1
Deleted, changed the interpreter (PyCharm to VS), changed the file paths.

Python: Importing "Text" from typing package

I trying to import Textfrom typing by,
from typing import Text
I am getting the following error,
Traceback (most recent call last):
File "<input>", line 1, in <module>
ImportError: cannot import name 'Text'
I am working on Python 3.5
Any advice?
This is a known problem with Python 3.5.0 and 3.5.1 - see https://github.com/python/mypy/issues/1838 and https://github.com/awslabs/aws-encryption-sdk-cli/issues/114.
As they say there, you can add try/catch blocks around the typing imports - or you can use an updated version of Python.

Module in list can't be imported

I know that this could be marked as a duplicate, but hear me out!
The questions like this one are horribly out of date and no longer apply to my needs!
I used help("Modules")to get a list of all installed modules.
The module I was looking for, "crypt" was in the list.
When I tried to import it in the shell and in a new file, I got the following error:
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
import crypt
File "C:\Users\Work\AppData\Local\Programs\Python\Python35-32\lib\crypt.py", line 3, in <module>
import _crypt
ImportError: No module named '_crypt'
Note:
I did not call it with an underscore
It looks like you are trying to run it on Windows -- crypt is a Unix-only library.
https://docs.python.org/dev/library/crypt.html

_psycopg of psycopg2 not found

So I have been using psycopg2 for a while now, but it is only now that I have encountered this error upon running our script.
Traceback (most recent call last):
File "engine/LinkOracleEngine.py", line 8, in <module>
from util.DoSQL import DoSQL
File "/home/zero/Documents/Thesis/Source Code/engine/util/DoSQL.py", line 4, in <module>
import psycopg2
File "/usr/lib/python2.7/dist-packages/psycopg2/__init__.py", line 50, in <module>
from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ImportError: No module named _psycopg
Why is that? From my previous uses, there was no problem in importing psycopg2, but now it has. I updated it and there seems no changes, I even installed another psycopg2 through pip3 but it is still the same.
I even tried importing sys in the python console, then appended the library where it was located (/usr/lib/python2.7/dist-packages/psycopg2/) to the sys.path, but still gets the same ImportError: No module named _psycopg.
>>> import sys
>>> sys.path.append('/usr/lib/python2.7/dist-packages/')
>>> import psycopg2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/psycopg2/__init__.py", line 50, in <module>
from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ImportError: No module named _psycopg
>>> sys.path
['', '/opt/anaconda2/lib/python27.zip', '/opt/anaconda2/lib/python2.7', '/opt/anaconda2/lib/python2.7/plat-linux2', '/opt/anaconda2/lib/python2.7/lib-tk', '/opt/anaconda2/lib/python2.7/lib-old', '/opt/anaconda2/lib/python2.7/lib-dynload', '/home/zero/.local/lib/python2.7/site-packages', '/opt/anaconda2/lib/python2.7/site-packages', '/opt/anaconda2/lib/python2.7/site-packages/Sphinx-1.3.1-py2.7.egg', '/opt/anaconda2/lib/python2.7/site-packages/cryptography-1.0.2-py2.7-linux-x86_64.egg', '/opt/anaconda2/lib/python2.7/site-packages/setuptools-18.5-py2.7.egg', '/usr/lib/python2.7/dist-packages/']
>>>
Last time I remembered doing was setting up a cluster between my laptop and PC with mpich and mpich4py, but that doesn't seem to directly affect my psycopg2 right? Correct me if I'm wrong.

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