How to setup libusb for a conda Python environment in Mac - python

So I'm trying to use pyusb in a conda environment but it fails with error below:
>>> import usb.core
>>> usb.core.find()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/foo/Developer/anaconda3/envs/delme/lib/python3.6/site-packages/usb/core.py", line 1263, in find
raise NoBackendError('No backend available')
I'm assuming this happens because it can't find libusb. I have tried installing libusb and libusb1 inside the conda environment via pip and also system-wide (libusb and libusb-compat) via brew but none of these have helped.

I figured out what's happening so I might as well answer my own question – someone else might find it useful.
For reasons that I don't remember anymore I had added some paths to DYLD_FALLBACK_LIBRARY_PATH when I was trying to compile something. According to dyld's manual the default value for DYLD_FALLBACK_LIBRARY_PATH is $(HOME)/lib:/usr/local/lib:/lib:/usr/lib which covers where libusb is but looks like by extending DYLD_FALLBACK_LIBRARY_PATH it's lost those default values.
So if you have similar issues you might want to take a look at these variables.

Related

install of mapnik on windows python

for my master thesis, I have to render some maps from OpenStreetMap information. Unfortunately, I'm not able to install mapnik.
In the manual (https://github.com/mapnik/mapnik/wiki/WindowsInstallation) it said I should Add ";C:\mapnik-v2.2.0\lib" to the PATH variable. In my case it is "C:\Users\User\Mapnik\lib". I cloned the git repo and updated it to v3.0.23. Like it said here: https://mapnik.org/pages/downloads.html
But in this location, I don't have lib. Also, I don't have bin. So I'm a little bit confused about how to install mapnik.
I would really appreciate your help.
Some more Information: OS is windows 10, For Python, I'm using Anaconda with a 2.7 Instance just for mapnik... even if I read, that I could go with python 3. For the rest of my code, I go with Python 3.8. For sure I would prefer to stay at 3.8 but if it only works with 2.7 I would also use that.
Error message: "(Mapnik) C:\Users\User\Mapnik\demo\python>python rundemo.py
Traceback (most recent call last):
File "rundemo.py", line 25, in
import mapnik
ImportError: No module named mapnik"

No module named tensorflow.python.platform on WSL

I found a great Medium article on creating a new neural network architecture that I wanted to try out. Of course, I get to the training part, and things start to fail.
I can't import TensorFlow. Whenever I do, I get the error
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/myusername/.virtualenvs/worldmodels/lib/python3.5/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import * # pylint: disable=redefined-builtin File "/home/myusername/.virtualenvs/worldmodels/lib/python3.5/site-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow File "/home/myusername/.virtualenvs/worldmodels/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow.py", line 25, in <module>
from tensorflow.python.platform import self_check ImportError: No module named 'tensorflow.python.platform'
Well, I looked at this which suggested importing in a different folder which did not work. I also tried exporting the PYTHONPATH variable, set to PYTHONPATH="/home/London/.virtualenvs/worldmodels/lib/python3.5/site-packages" and PYTHONPATH="${PYTHONPATH}:/usr/local/lib/python2.7/dist-packages/" and PYTHONPATH="/usr/local/lib/python2.7/dist-packages/", all to no avail.
This one seemed to be a language issue, which shouldn't be my problem (and if it is, I don't know what they did to fix it.)
This one gave the same folder changing advice. This one seemed to be an issue with someone's command, not just trying to import it. And this one again suggests the setting PYTHONPATH. (And yes, I did see this one, but both the question and answer quality are lacking.)
Any ideas as to what I could do to get TensorFlow up and running?
(Maybe using a different install process than just pip? I have already tried installing by running sudo pip install tensorflow. I would still like to be able to use it with the Medium tutorial though.)
The issue was resolved by typing
pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.8.0-cp35-cp35m-linux_x86_64.whl
#ProQ does a better job explaining how they were able to resolve it!
It looks like there was some other weird stuff going on. The biggest thing I noticed that was odd is that sudo pip --version gave a different version than just pip --version.
Doing pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.8.0-cp35-cp35m-linux_x86_64.whl upgraded and allowed me to import tensorflow. (Note that doing sudo pip did not work.)
Thank you #HarisNadeem for the solution and for helping diagnose the issue!

Trying to download modules but python can't find them

So I need some modules for a project and after trying a lot of things and googling a lot of things I still can't get it to work. I used this code to test if the module was working:
import sys
sys.path.append('c:\users\my name\anaconda2\lib\site-packages')
import numpy
x = randn(100,100)
And I got this error:
Traceback (most recent call last):
File "C:\Users\My Name\Desktop\test.py", line 3, in
import numpy
ImportError: No module named numpy
Any idea why I'm doing wrong?
You can try two things:
1) which python
And see what python you are using. You may be still pointing to old python the system has. In that case add ~/anaconda2/bin to $PATH environment variable.
2) sys.path.append('c:\users\my_name\anaconda2\lib\python2.x\site-packages')
Usually anaconda library is installed under lib\pythonx.x(the correct python version number)\site-packages. So change that.
If none of the above worked, then just do clean install from scratch all over again.

IPython kernel restarts after installing new module

I was using "ipython" with "qtconsole" (it works perfectly) after I install some new third-party module and the "notebook" it stops working and the kernel restarts continually.
the Error is here:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/IPython/kernel/__init__.py", line 10, in <module>
raise ImportError(__doc__)
ImportError: IPython.kernel has been replaced by IPython.parallel.
The previous version of IPython's parallel library was located at this
location (IPython.kernel). It has been moved to the IPython.parallel
subpackage and has been refactored to use zeromq/pyzmq instead of twisted.
Please see INSERT URL for further details.
[IPythonQtConsoleApp] WARNING | kernel restarted
how can I fix this issue?
the Error says "Please see INSERT URL for further details." where can I find this "INSERT URL" ???
thank you.
You have multiple versions of IPython installed, and it's getting confused. The version in /usr/lib is installed with apt, and old (pre-1.0).
The shortest workaround, if available to you, would be to apt-get remove ipython, leaving only one IPython on your system.
The most likely cause of this issue, since you say it was caused by installing another package, is easy_install. It is possible for easy_install to incorrectly add dist-packages to easy-install.pth when you already have a package installed with apt. To check this, look at the files (if they exist):
~/.local/lib/python2.7/site-packages/easy-install.pth
/usr/local/lib/python2.7/dist-packages/easy-install.pth
If there are any entries starting with /usr/lib/python2.7/dist-packages, they should be removed.

Arrow keys not working with Enthought python

If I use the arrow keys in either python or ipython, I don't get what I should, but instead a weird combination of characters: everything is like in this thread, except that I never compiled python from source.
What happened is roughly this: for some mysterious reasons that nobody was able to decipher (see this thread on ubuntuforums), my Kubuntu user stopped working properly and I had to set up a new one. On this new users, I didn't have Enthought python, so I performed (I hope) a global installation of it - and Canopy.
On this python, the arrow keys don't work.
Can you please help me? Please be patient, I'm a beginner...
Thanks in advance!
EDIT: output of python -c 'import readline':
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named readline
EDIT2: Inspired by your comments, I tried the following
/usr/local/Canopy_32bit/User/bin/python setup.py install
for the readline module: it worked!!!
I couldn't get rid of Enthought python as I need all of the packages for scientific computation. Thanks a lot guys, you helped!
If running the command python -c 'import readline' gives you the following output:
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: libreadline.so.5: cannot open shared object file: No such file or directory
then you need to install the older libreadline in your system. On Ubuntu/Kubuntu it is libreadline5 , on Fedora it is compat-readline5
I don't have enough reputation to comment, so I have to put this in as an answer, but when installing Enthought did you by any chance replace your original python install on your machine? I vaguely remember the install script asking me whether I wanted to make Enthought my default python install.
You might still need to rebuild your Python as posted in the original question that you linked.

Categories

Resources