CLIPSpy: Getting "No module name 'clips._clips'" upon importing clips - python

I have installed CLIPSpy from the git repository, and followed the instructions for installing with the source files. Yet after installing and running the python shell I get this error:
`import clips
.../clipspy/clips/__init__.py", line 30, in <module>
from clips.error import CLIPSError
.../clipspy/clips/error.py", line 32, in <module>
from clips.router import Router
.../clipspy/clips/router.py", line 7, in <module>
from clips._clips import lib, ffi
ModuleNotFoundError: No module named 'clips._clips'`
Despite this error, if I run the same commands outside of my CLIPSpy directory, I can import clips but get a different error.
>>> import clips
>>> env = clips.Environment()
>>> env.assert_string("(test 12)")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'Environment' object has no attribute 'assert_string'
My assumption is that ModuleNotFoundError may be responsible for the AttributeError.
OS: Arch Linux
git-repo: https://github.com/noxdafox/clipspy
I followed the advice of specifying the directory of clips, using pyclips and import clips as a python module, to specify the location of clips but it still gives me the same error.
Installing CLIPSpy via pip gave 'satisfactory' results: ModuleNotFoundError: No module named 'pygame'
Requirement already satisfied: clipspy in /usr/lib/python3.7/site-packages/clipspy-0.3.2_2_g7dd9ca2-py3.7-linux-x86_64.egg (0.3.2-2-g7dd9ca2)
Requirement already satisfied: cffi>=1.0.0 in /usr/lib/python3.7/site-packages (from clipspy) (1.12.2)
Requirement already satisfied: pycparser in /usr/lib/python3.7/site-packages (from cffi>=1.0.0->clipspy) (2.19)
I tried re-installing clipspy via github many times, but the same issue persists. The interesting part is that I used pyclips as alternative for a while and it gave me the same error. It might be something to do with the directory or the installation, but I am not sure what it could be.
The installation process for CLIPSpy was as follows:
make:
python setup.py build_ext --include-dirs clips_source \
--library-dirs clips_source
/usr/lib/python3.7/site-packages/setuptools/dist.py:484: UserWarning: The version specified ('0.3.2-2-g7dd9ca2') is an invalid version, this may not work as expected with newer versions of setuptools, pip, and PyPI. Please see PEP 440 for more details.
"details." % self.metadata.version
running build_ext
generating cffi module 'build/temp.linux-x86_64-3.7/_clips.c'
already up-to-date
I tried re-installing setuptools to see if I could get a valid dist.py version, but alas nothing has changed.
sudo make install:
....
Installed /usr/lib/python3.7/site-packages/clipspy-0.3.2_2_g7dd9ca2-py3.7-linux-x86_64.egg
Processing dependencies for clipspy===0.3.2-2-g7dd9ca2
Searching for cffi==1.12.2
Best match: cffi 1.12.2
Adding cffi 1.12.2 to easy-install.pth file
Using /usr/lib/python3.7/site-packages
Searching for pycparser==2.19
Best match: pycparser 2.19
Adding pycparser 2.19 to easy-install.pth file
Using /usr/lib/python3.7/site-packages
Finished processing dependencies for clipspy===0.3.2-2-g7dd9ca2
The solution could be something simple, but I can't seem to know what it is.
Any help or advice on what to do or where I went wrong would be greatly appreciated.
EDIT 1:
After removing files related to clips, and having a fresh install, I no longer receive the Atribute Error. Rather I get an ImportError
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.7/site-packages/clipspy-0.3.1-py3.7-linux-x86_64.egg/clips/__init.py", line 30, in <module> from clips.error import CLIPSError
File "/usr/lib/python3.7/site-packages/clipspy-0.3.1-py3.7-linux-x86_64.egg/clips/error.py", line 32, in <module> from clips.router import Router
File "/usr/lib/python3.7/site-packages/clipspy-0.3.1-py3.7-linux-x86_64.egg/clips/router.py", line 7, in <module> from clips._clips import lib ffi
Import Error: libclips.so: cannot open shared object file: No such file or directory
I've cloned the git repository that contains tag 3.2
EDIT 2:
Managed to fix the error by renaming the libclips.so.6 file located in the /usr/lib/ folder to libclips.so
Now it works.

I am the author of the clipspy module. I would rather suggest you to open a GitHub issue for these types of matters rather than a SO question.
As a general line, the issues you are suffering from indicate you are trying to install a Python module in a dirty environment. For example, installing via pip resolves in a noop because you ran make install beforehand and pip sees the package is already installed.
To install from git, you either git clone a specific tag or download the code from a specific release. clipspy uses tags to infer the version numbers hence you see the warning:
UserWarning: The version specified ('0.3.2-2-g7dd9ca2') is an invalid version, this may not work as expected with newer versions of setuptools, pip, and PyPI. Please see PEP 440 for more details.
A common issue when installing clipspy is an old version of setuptools. Have you tried updating it to a more recent version?
# pip install --upgrade setuptools
One last note, do you happen to also have PyCLIPS installed within the system? The namespaces will conflict as the modules are both called clips. This would explain the error traceback:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'Environment' object has no attribute 'assert_string'

Related

Why cant I use my newly downloaded python library?

So ive tried to install customtkinter and the installation was successfull
Using cached customtkinter-4.6.3-py3-none-any.whl (246 kB)
Requirement already satisfied: darkdetect in c:\users\omen1\appdata\local\programs\python\python311\lib\site-packages (from customtkinter) (0.7.1)
Installing collected packages: customtkinter
Successfully installed customtkinter-4.6.3
But when i then go to vs code and write import customtkinter and run it says
Traceback (most recent call last):
File "c:\Users\OMEN1\OneDrive\Skrivbord\python projects\database.py", line 290, in <module>
import customtkinter
ModuleNotFoundError: No module named 'customtkinter'
I have tried to uninstall and re-install
My pip is also fully uppdated aswell as my python 3.11
Ive tried multiple things
Ensure that the interpreter you're using in VSCode is aligned to where you installed the library.
For example if you installed it with Python3, your VSCode may be pointed to Python2 instead.
Additionally, according to the PyPi link for that library - "To use CustomTkinter, just place the /customtkinter folder from this repository next to your program, and then you can do import customtkinter."

How do I import rubberband after successful installation with pip and pip3?

I'm attempting to use rubberband and coming across errors I haven't seen before, nor know how to resolve.
First, I installed via terminal with both pip and pip3. rubberband appears in pip freeze and pip3 freeze as version 0.2.0.
When I import rubberband the python editor in terminal, the common error is returned:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named rubberband
When I import rubberband the python3 editor in terminal, the unusual error is returned. (This error also appears during import in jupyter notebook):
>>> import rubberband
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/rubberband.cpython-37m-darwin.so, 2): Library not loaded: /usr/local/lib/libsndfile.1.dylib
Referenced from: /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/rubberband.cpython-37m-darwin.so
Reason: image not found
I think it is notable that import in python and python3 returns different error messages. From there, I am having trouble troubleshooting.
Thanks in advance!
Edit: Tharun K commented to check the dependencies: librubberband and libsndfile. Below are the error messages returned when attempting to install librubberband. (same errors applied for libsndfile)
$ pip3 install librubberband
ERROR: Could not find a version that satisfies the requirement librubberband (from versions: none)
ERROR: No matching distribution found for librubberband
$ python3 -m pip install "librubberband==1.8"
ERROR: Could not find a version that satisfies the requirement librubberband==1.8 (from versions: none)
ERROR: No matching distribution found for librubberband==1.8
$ python3 -m pip install "librubberband~=1.8"
ERROR: Could not find a version that satisfies the requirement librubberband~=1.8 (from versions: none)
ERROR: No matching distribution found for librubberband~=1.8
Edit 2: Solution from Tharun K "Michael, firstly, I'd mentioned libsamplerate and libsndfil formulae.brew.sh/formula/libsndfile formulae.brew.sh/formula/libsamplerate – Tharun K"
libsamplerate and libsndfil needed to be installed with brew.
You can try the solution:
Source : https://github.com/bmcfee/pyrubberband/issues/18#issuecomment-786515163
Download rubberband library ( folder containing rubberband.exe and libsndfile-1.dll
Go to Windows System Environment and Add the folder to Path
Create System Variable with Variable name "rubberband" and path to the rubberband.exe
Make sure all your relevant users can access the path and the rubberband variable (for me, I had to set it up for the admin account and my local user account). This can be checked by opening cmd and typing "rubberband". If the command works, the library is recognized.
Restart the Program in which you want to access the library (e.g. restart Visual Studio)
The answer to the problem was to install pyrubberband with brew, rather than pip.

Installing socketio module on python3 seems to be corrupting pip

While installing the socketio package for python using pip3 install socketio, I got the following results:
ERROR: launchpadlib 1.10.13 requires testresources, which is not installed.
WARNING: The scripts easy_install and easy_install-3.8 are installed in '/home/bill/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed netifaces-0.10.6 setuptools-3.3 socketio-0.2.1
Although I was able to import socketio successfully, pip3 seems corrupted(?).
Specifically, when trying to run anything including pip3, even pip3 by itself in the terminal, I get the same error:
Traceback (most recent call last):
File "/usr/bin/pip3", line 6, in <module>
from pkg_resources import load_entry_point
File "/home/<username>/.local/lib/python3.8/site-packages/pkg_resources.py", line 1479, in <module>
register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 144, in apport_excepthook
with os.fdopen(os.open(pr_filename,
FileNotFoundError: [Errno 2] No such file or directory: '/var/crash/_usr_bin_pip3.1000.crash'
Original exception was:
Traceback (most recent call last):
File "/usr/bin/pip3", line 6, in <module>
from pkg_resources import load_entry_point
File "/home/<username>/.local/lib/python3.8/site-packages/pkg_resources.py", line 1479, in <module>
register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'
I tried reinstalling pip3 but it didn't help. I migrated from ubuntu to mint thinking it is something buggy with the distribution but same results. I also corrupted ubuntu when I tried to remove python and reinstall it since I couldn't use pip, but, you know what they say, live and learn.
Edit: Nothing on using pip3: module "importlib._bootstrap" has no attribute "SourceFileLoader" works for me.
I am currently using linux mint 20, but I experienced the same problem on ubuntu 20.04 and 20.04.1.
Any ideas would be appreciated!
Perhaps you meant this socketio instead?: https://pypi.org/project/python-socketio
python3 -m pip install python-socketio
The package literally named "socketio" seems like it may simply be old and unsupported1, while "python-socketio" seems alive and developed 2 3
To that end, it's often valuable to take a look at similar packages and also to watch out for typosquatting et al. when installing packages via pip!
Edit: Martijn Peters makes a good point that this is the socketio you are looking for: https://pypi.org/project/python-socketio
Read on if you need a solution for the original one you posted about.
Summary: pip3 install git+https://github.com/allenmcgehee/socketio-0.2.1-patched
I was able to reproduce this in a docker container running ubuntu:20.04 exactly as you described which gave me some hope that I could help out.
I found that socketio had a dependency for setuptools==3.3 which seemed odd to me, but lines up with why the core functionality of pip was breaking after installing socketio.
I am not sure where this package is maintained as there is no git repo referenced. I did find a Russion website in the PKG-INFO, but I wasn't sure where to go from there...
Here is a version of socketio with a requirement of setuptools>=42 so that nothing gets broken: https://github.com/allenmcgehee/socketio-0.2.1-patched
And finally, here is the single command that should install socketio for you without breaking pip:
pip3 install git+https://github.com/allenmcgehee/socketio-0.2.1-patched
**I am assuming you've already fixed pip.
This happened to me with a different module. My solution was to down-grade the version of pip and the version of the module. So, for you the answer would be to run:
python -m pip install pip== (previous version of your pip)
python -m pip uninstall socketio
python -m pip install socketio==0.2.0

couldnt install python-colorama

I am trying to install Jarvis ai from https://github.com/sukeesh/Jarvis (I know it is not meant to be installed on windows 10. but I try it anyway)
It said no module named colorama, so I typed pip install python-colorama. Then it said
Could not find a version that satisfies the requirement python-colorama (from versions: )
No matching disribution found for python-colorama
I tried to install it using ubuntu, but different problem occurs: it said
Specify python version(2/3)(Default-3)3
Selected python version 3
Running virtualenv with interpreter /usr/bin/python3
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 22, in <module>
import distutils.spawn
ModuleNotFoundError: No module named 'distutils.spawn'
So its like asking 2 question in one. On windows it is
C:\Users\badarsyah\Jarvis>pip install python-colorama
Collecting python-colorama
Could not find a version that satisfies the requirement python-colorama (from versions: )
No matching distribution found for python-colorama
But on ubuntu 18.04
aiki#LAPTOP-886AEJJG:~/Jarvis$ ./setup.sh
Specify python version(2/3)(Default-3)3
Selected python version 3
Running virtualenv with interpreter /usr/bin/python3
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 22, in <module>
import distutils.spawn
ModuleNotFoundError: No module named 'distutils.spawn'
I hope anyone can help, but please read the GitHub first so you can understand what im trying to do.
I managed to solve this problem by simply update pip with
python -m pip install -U pip
then ran again the install command.

Accidentally installed two versions of Python 3.4.1... Can't run any scripts, no modules can import, how can I fix this?

I was having problems with a 'zlib' import error on Python3.4.1, so I followed the instructions here, but instead of doing it for Python 2.6 I did it for 3.4. I had not uninstalled my existing version of Python3.4 before doing this new installation process. I can now import zlib, however all of my custom packages cannot be imported, such as sklearn, scipy, numpy, flask, and pandas.
First, I get an import error:
>>> import scipy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'scipy'
So, I try to remedy the issue with:
pip3 install scipy
But, I am greeted with:
Requirement already satisfied: scipy in /usr/local/lib/python3.4/dist-
packages
Requirement already satisfied: numpy>=1.8.2 in
/usr/local/lib/python3.4/dist-packages (from scipy)
I tried running echo $PYTHONPATH but it returned blank.
I can import sys, os, time, and zlib just fine. It just won't import all of the dependencies that I already have on my computer.
I tried deleting the folder in /tmp where I installed the "newer" Python3.4.1 folder, however this did not work. I don't know how to fix this issue.
I can still run python scripts in an anaconda virtual environment that I had created a while ago, but I can't use virtualenv's, which is a problem since I use zappa a lot (which requires an active virtualenv).
This is what I get when I try to run a virtualenv:
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'
Current thread 0x00007fb1bc7f4740 (most recent call first):
Aborted (core dumped)
The python version that contains all of my dependencies in dist-packages is located in /usr/local/bin/python3.4. How can I make it so that when I run python3 that it will use the dependencies from that folder? Is the fact that the pythonpath variable is blank bad?
I just want my old python back.
PS. Everything works fine for python2. It's just causing these issues for python3.
I had a similar issue, but with another package. In my case it turned out that I had a egg-info file present in the site-packages without the directory for the package. Deleting the egg-info file (actually I moved it first) allowed a clean install to occur.

Categories