I'm trying to use the ReadIM package with an anaconda environment (anaconda 4.7.12, python 3.8, pip 19.3.1), thus requiring me to use pip install readIM which succeeds, with the package found in conda list and pip list.
I have read a lot of posts talking about using the correct python and pip paths, my python where shows only my anaconda path, where I ran conda install pip beforehand, and then pip -V shows my pip is in my conda path.
I have tried conda update --all and pip uninstall readIM. I also read that it could be an issue with Jupyter notebook, hence in the conda command prompt I tried python then import readIM, which still gave me the same import error.
As advised on the source page, I tried installing by running python setup.py build install/python setup.py install in the source directory, however this gave me an error
cygwin TypeError: '>=' not supported between instances of 'NoneType' and 'str'
I am at a loss, any ideas?
Thanks,
Mustafa.
UPDATE:
Managed to compile it from source successfully, but still get the same error:
(base) C:>python -m pip install ReadIM-0.8.2.tar.gz
Processing c:\readim-0.8.2.tar.gz
Building wheels for collected packages: ReadIM
Building wheel for ReadIM (setup.py) ... done
Created wheel for ReadIM: filename=ReadIM-0.8.2-cp37-cp37m-win_amd64.whl size=219546 sha256=90f8960a6f1f80ae62dc18eab4bcd31fb2a6dfd7da364a5c15fc37e6e2ce0360
Stored in directory: C:\Users\mi4517\AppData\Local\pip\Cache\wheels\d6\a9\11\936e986255027bb654601b322a3431f9bcc3fde72ebb406835
Successfully built ReadIM
Installing collected packages: ReadIM
Successfully installed ReadIM-0.8.2
(base) C:>python
Python 3.7.5 (default, Oct 31 2019, 15:18:51) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
import readIM
Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'readIM'>
Following their instructions (python setup.py build install then python setup.py test) yields a successful build but a failed test:
C:\ReadIM-0.8.2>python setup.py test
Traceback (most recent call last):
File "setup.py", line 41, in
assert os.path.isdir(testFileDir)
AssertionError
SOLUTION
It was installing correctly, just that I was importing it incorrectly in Python. I was doing import readIM or import readim when it should be import ReadIM I did not know it was case sensitive!
Thank you for your help, apologies for the trivial mistake on my part.
I had faced a similar issue. With your conda environment activated, type
which pip
Check if it shows the path to pip in your environment. In my case, it was not. It was showing path to some other pip. So pip install was installing in that environment. To fix use the full path of pip, like below
~/anaconda3/envs/my_env/bin/pip install ...
To avoid this issue follow these steps
open Anaconda prompt
type this command conda install -c conda-forge imread
after installation open jupiter notebook.
type import imread then run.
It was installing correctly, just that I was importing it incorrectly in Python. I was doing import readIM or import readim when it should be import ReadIM I did not know it was case sensitive!
Thank you for your help, apologies for the trivial mistake on my part.
Related
I recently bought a MacBook Air with the Apple M1 chip, and I'm trying to install keras for Python 3.9.10 (installed using homebrew). Using the command
pip3 install keras
in the terminal, I get the following output:
Collecting keras
Using cached keras-2.8.0-py2.py3-none-any.whl (1.4 MB)
Installing collected packages: keras
Successfully installed keras-2.8.0
Next, I entered the following series of commands (find output included as well):
~ % python3
Python 3.9.10 (main, Jan 15 2022, 11:40:53)
[Clang 13.0.0 (clang-1300.0.29.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import keras
After running the last line (import keras), I got the following output in the terminal:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/homebrew/lib/python3.9/site-packages/keras/__init__.py", line 21, in <module>
from tensorflow.python import tf2
ModuleNotFoundError: No module named 'tensorflow'
My understanding was that keras is built on top of TensorFlow, however this seems to indicate that I need TensorFlow installed on my computer as well. Is this correct? Or is there something else I'm missing?
I've heard that TensorFlow can be very difficult to install on Apple M1 computers, so I've been trying to avoid doing so, but if I do need to, how should I go about it?
Thank you ahead of time.
UPDATE:
I decided to try and install TensorFlow2 in the terminal using the command
pip3 install tf2
and got the following output:
ERROR: Could not find a version that satisfies the requirement tf2 (from versions: none)
ERROR: No matching distribution found for tf2
I guess this is where the difficulty starts... is there any straightforward way to install TensorFlow2 on an Apple M1 computer? I'd really prefer not to switch compilers or anything as I don't have a great deal of experience with macOS and don't want to make any irreversible mistakes.
Thank you again.
UPDATE 2:
I just tried the command
pip3 install tensorflow
and I got the following output:
ERROR: Could not find a version that satisfies the requirement tensorflow (from versions: none)
ERROR: No matching distribution found for tensorflow
Thank you to Dr. Snoopy for pointing out that the package was called tensorflow and not tf2. I've read the problem might have something to do with a missing multi-threading file or something, but still can't figure out how to fix it.
A tested method using conda:
Ensure you upgrade Mac OS X > 12.3.
Install XCode CLI tools
xcode-select --install
Install Miniforge. I prefer installing using brew
brew install miniforge
Create a conda environment and activate it
conda create --name tensyflow python=3.8
conda activate tensyflow
Install Tensorflow-MacOS
conda install -c apple tensorflow-deps
pip install tensorflow-macos # or pip3
I installed telegram packages. But when I try to run the simple example, echobot.py, I got an error:
Traceback (most recent call last):
File "echobot.py", line 8, in <module>
import telegram ImportError: No module named 'telegram'
Can anyone help me?
I install using git:
$ git clone https://github.com/python-telegram-bot/python-telegram-bot
after this:
$ python -i
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:01:18) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
import telegram
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'telegram'
You are not installing it. You are just downloading it.
Run these:
cd python-telegram-bot
python setup.py install
(stated in readme of the GitHub page)
Alternatively, you can use pip. It's easier to use.
pip install python-telegram-bot
For my case, I solved it this way.
pip install telegram
I noticed when I import telegram.ext, it does not find .ext. The issue was caused by telegram and python-telegram modules being installed. Delete these and install only python-telegram-bot. It should work.
Thre problem is in line with smth like
sys.path.append(os.path.join(os.path.abspath('.'), 'lib'))
in bot_gae.py.
You have to point at REAL place, where you've installed python-telegram-bot.
In my case it's ./lib in project directory.
If you have named your python file as telegram.py then it will throw this error because the program is calling ext function from the file itself.
Try renaming your python file to something else it will work.
In my case, I had two python versions installed.
A quick solution is to idetify which python your code is using. Then go to bin directory where the python is installed. Find the pip binary name inside that using command
ls -lrt | grep pip
In my cases the name was pip3.6. So use then use that pip name and execute from same directory
pip3.6 install python-telegram-bot
Long term fix is to add your pip3.6 shortcut in /usr/bin or /usr/loca/bin and install packages using pip3.6 command
Try to uninstall it by pip uninstall python-telegram-bot
And after that install it again pip install python-telegram-bot
Install
pip install django-telegrambot
Configure your installation
settings.py
INSTALLED_APPS = (
...
'django_telegrambot',
)
I'm new in python, but all search results i found was useless for me.
C:\Users\Aero>pip install wkhtmltopdf
Collecting wkhtmltopdf
Using cached wkhtmltopdf-0.2.tar.gz
Installing collected packages: wkhtmltopdf
Running setup.py install for wkhtmltopdf
Successfully installed wkhtmltopdf-0.2
C:\Users\Aero>python
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import wkhtmltopdf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python34\lib\site-packages\wkhtmltopdf\__init__.py", line 1, in <module>
from main import WKhtmlToPdf, wkhtmltopdf
ImportError: No module named 'main'
That is happening all the time. Thanks for any help.
Update:
I find that installing Python 2.* makes it okay, cause of main module isn't correct while using print (Using 2.* version).
But i still want to know, it there any ways?
i solve it installing it this way, i hope it work for you
pip install django-wkhtmltopdf
It wasn't working for me for the first time, but after a PyCharm restart I could see anything. This might work for you: (Tested on Python 3.3.0)
import wkhtmltopdf
from wkhtmltopdf.main import WKhtmlToPdf
var = WKhtmlToPdf(
url='http://www.example.com',
output_file='~/example.pdf',
)
var.render()
If none of the other options work, it might be something wrong with your cache. Try uninstalling wkhtmltopdf and django-wkhtmltopdf and reinstalling without the cache:
pip uninstall django-wkhtmltopdf wkhtmltopdf
pip install --no-cache-dir wkhtmltopdf==0.2
pip install --no-cache-dir django-wkhtmltopdf==3.2.0
(Note that the above wkhtmltopdf and django-wkhtmltopdf version numbers may be different in your case.)
Seems there is some error with package installation of wkhtmltopdf. It wasn't working for me then i uninstalled the package and re-installed it by doing
python -m pip uninstall wkhtmltopdf
and then
python -m pip install wkhtmltopdf
it worked for me.try this it may work.
I am a bit of a noob on Mac and my python installation is refusing to acknowledge the existence of the rpy2 module on my mac. It looks like it only sees it as a Python 2.6 module. How do I make it visible in 2.7 ? Do I need to downgrade my python ? If so, how ? On the RPy2 web page (http://rpy.sourceforge.net/rpy2_download.html) Python 2.6 is recommended. Thanks!
mayumi#MAYUMI-iMac~:/ python --version
Python 2.7.6
mayumi#MAYUMI-iMac~:/ pip install rpy2
Requirement already satisfied (use --upgrade to upgrade): rpy2 in /Library/Python/2.6/site-packages/rpy2-2.3.8-py2.6-macosx-10.6-universal.egg
Cleaning up...
mayumi#MAYUMI-iMac~:/ python
Python 2.7.6 (v2.7.6:3a1db0d2747e, Nov 10 2013, 00:42:54)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import rpy2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named rpy2
>>>
I also found it is difficult to successfully install rpy2 in OSX machines. Sometime it works, sometimes it doesn't, which is very annoying. I eventually settled with Anaconda Python distribution from https://store.continuum.io/cshop/anaconda/ to save all the troubles. Installing rpy2 never fails since the switch.
The default installation of Anaconda does not included rpy2, so you want to run the installation command, from Anaconda folder, bin subfolder
conda install rpy2
Depends on the version, you may get a bunch of warnings. Just ignore them.
Then rpy2 just works! Of course, only under the Anaconda python, not the other python version you may have installed on your machine.
You can run a few test to make sure rpy2 works, following this example: http://nbviewer.ipython.org/urls/raw.github.com/ipython/ipython/3607712653c66d63e0d7f13f073bde8c0f209ba8/docs/examples/notebooks/rmagic_extension.ipynb
bash commands, run in the folder /Users/YOUR_USER_NAME/anaconda/bin/:
user-Mac-Pro:bin user$ conda install rpy2
and it says:
Conda package not available for rpy2, attempting to install via pip
Downloading/unpacking rpy2
Downloading rpy2-2.3.8.tar.gz (185kB): 185kB downloaded
Running setup.py egg_info for package rpy2
If you don't have R installed it will complain with a few warnings and fetch R for you. Then there may be some other depreciation warnings dependents on what you have installed.
(I am not associated with Continuum in any way)
You can see that pip installed to the site-packages to python 2.6 since you installed pip with python 2.6 it will default to use that library.
rpy2 in /Library/Python/**2.6**/site-packages/rpy2-2.3.8-py2.6-macosx-10.6-universal.egg
You can redirect pip installation location or use easy_install2.7 which should be around in /usr/local/bin/
(NB: see this other post for why I am not using dpkg/apt-get/etc. for this installation.)
I can install numpy in a virtualenv on Debian with, e.g., pip:
(base)[1778]% pip -v install numpy
Downloading/unpacking numpy
...
<output omitted>
...
Successfully installed numpy
Cleaning up...
Removing temporary dir /home/jones/.virtualenvs/base/build...
But immediately after this:
(base)[1779]% python
Python 2.7.1 (r271:86832, Jun 22 2011, 15:39:05)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named numpy
>>> ^D
Any ideas?
OK, I found the problem. It turns out that, even though my virtualenv is active (see the (base) prefix to the command-line prompts in the screen interaction snippets above), I still need to tell pip to use it. E.g. after running something like
pip -E /path/to/virtualenv install numpy
then importing numpy within an interactive python session succeeds (whether the imported module is functional, I don't know yet).
This is absurd: my virtualenv is active, and the pip executable I'm running is the one installed in that virtualenv:
(base)[1801] which pip
/home/jones/.virtualenvs/base/bin/pip
So what's the point of having a virtualenv if pip will not use it by default???
I'm guessing that your virtualenv is not actually active?
You might also run into problems with this bug: https://bugs.launchpad.net/ubuntu/+source/python-virtualenv/+bug/780220
There is a similar question here: Windows + virtualenv + pip + NumPy (problems when installing NumPy)
perhaps some of the answers there may help you.
regarding the last error for command:
pip -E /path/to/virtualenv install numpy
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
Here is solution to that problem.
Upgrade to latest virtualenv:
sudo pip install --upgrade virtualenv
create your python virtualenv and run
pip -E /path/to/virtualenv install numpy
Regards, Karlo.