When I import Bio in a Jupyter notebook in Anaconda on a Mac I this error: No module named 'Bio'.
Somehow the import settings weirdly case sensitive. This will fix it:
# Installing the biopython libraries in this runtime environment
!pip3 install biopython==1.78
# The next two lines fix the error "No module named 'Bio'"
# that occurs with an Anaconda Navigator installation on OSX
# by making python imports case insensitive
import os
os.environ['PYTHONCASEOK'] = '1'
# On to regularly scheduled imports.
import Bio
Further experiments show that other permutations won't work in both google colab and Jupyter; and I am not sure why:
I have run some experiments with this and after uninstalling all bio and biopython variants (just to be sure, they were not actually installed), I fount that
!pip3 install bio
import bio
works on anaconda but not on google colab. If I import Bio with a capital B it works on neither of them.
!pip3 install bio
import os
os.environ['PYTHONCASEOK'] = '1'
import Bio
print("All's well")
works on Jupyter but errors out "ModuleNotFoundError: No module named 'Bio'" on collab. Import lower case bio behaves the same.
# Solution that works on both colab.google.com and
# Anaconda Navigator Jupyter notebooks
!pip3 install biopython
import os
os.environ['PYTHONCASEOK'] = '1'
import Bio
works for Anaconda Jupyter and Google Colab. If you change the case to 'import bio' it stops working on Google.
Related
im using Pycharm 2022.2.3.
I have Anaconda Navigator 2.3.2. Created in anaconda a new virtual environment based on python 2.7 called testpy2. Added the numpy package needed to execute a code. I did it from Ananconda Navigator GUI. The installation was succesful. I could see now numpy in my installed package list.
Open Pycharm project, select as interpreter the existing conda environment test2py.
The code is:
import random
import numpy as np
print "Hola"
The problem is it give the error: ImportError: DLL load failed when importing Numpy.
So I cant execute the program because of numpy.
When i go to see the packages something similar to:
then i got stuck in loading. Pycharm should recognize and load all the packages in the conda environemnt as shown in the image above, but in my case i got stuck in loading.
Im running on Windows 10 and i dont have any python installed at all
Any help would be apreciated.
On import modin.pandas as modin_pd line I get ModuleNotFoundError: No module named 'modin'. I am using poetry & JupyterLab. If in the cell I type !poetry add modin, I get ValueError saying Package modin is already present.
So it cannot install modin because it is already installed but it cannot import it either. Any obvious solution that I am missing?
pip freeze command also shows modin to be installed. I also tried to install it via pip install but absolutely nothing let me to import this module in the end.
The problem may be this one KeyError: CPU
It can be solved by using pip install psutil
Getting the No module named 'matplotlib.pyplot'; matplotlib is not a package error when trying to run:
import matplotlib.pyplot
plt.plot([1,2,3,4],[4,7,8,12])
plt.show()
Im running python 3.3, and have installed the correct matplotlib, and six library. i have checked this by running pip list.
I have also tried running the file in terminal, and when i do this the error changes from matplotlib is not a module to no module named pyplot.
I just installed python in my MacOS using the Anaconda distribution. My problem is although the packages (eg. matplotlib, numpy, scipy) came included with the installation, I have to import them to spyder every time which is tedious and it's also tiring that that I have to remind spyder of their functionalities.
For eg, in Windows, I only needed to type in the console:
x=array([...,...,...])
but in my mac it would have to be:
import numpy as py
and then type into the console:
x=py.array([...,...,...])
I do notice that in that the spyder-python console (Windows version), there is a text saying,
Imported NumPy 1.8.1, SciPy 0.13.3, Matplotlib 1.3.1 + guidata 1.6.1, guiqwt 2.3.2
Type "scientific" for more details.
That is probably the reason why I don't have to import anything in Windows because Spyder already did it.
How do I do the same for Mac?
Thank you
I'm using python 2.7 installed via macports, pyobjc, cocoa and notably scipy (via FlowCytometryTools) with py2app to create a small mac application. Py2app's setup.py run with sudo python setup.py py2app completes nicely with -A for testing, but is unable to complete when running without that parameter to create a full .app build.
The build process will get a variable distance through the unconditional imports and then give error: [Errno 35] Resource temporarily unavailable and immediately exit. The number of unconditional import lines that complete before the error occurs changes. The longest run so far was seen when running immediately after a reboot. I've tried running with and without removing the previous build/dist folders to no effect.
Modules not found (unconditional imports):
...
* builtins.int (Cython.Build.Inline, Cython.Compiler.ExprNodes, IPython.utils._tokenizeerror: [Errno 35] Resource temporarily unavailable
My setup.py looks like this:
import sys
sys.setrecursionlimit(1500) #required to avoid recursion triggered early exit in py2app while compiling scipy. (default is 1000)
from setuptools import setup
APP = ['FlowMac.py']
DATA_FILES = ['FlowMac_Main.xib']
OPTIONS = {'argv_emulation': True}
setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)
and the imports section of my python file FlowMac.py looks like this:
from Cocoa import *
from Foundation import *
from AppKit import *
from FlowCytometryTools import * #file/data handling via scipy and pandas
from pylab import * #graphing histograms
Commenting out both the FlowCytometryTools and the pylab imports allows the py2app build to complete but of course renders the program nonfunctional.
What is happening?
How can I get more information on which resource is unavailable?
was hitting a recursion limit a clue to my problem?
I'm running Yosemite on a MacBook Pro with 8GB RAM, so I'm very surprised to be hitting a wall here.
Thanks for your time.
UPDATE 4/29/2015:
Importing everything works fine if I remove my .xib from the datafiles array of the py2app launcher setup.py. A blank file with just import Cocoa, Foundation and Appkit works fine. Importing the xib with any one of FlowCytometryTools, pylab, scipy, matplotlib, numpy does not work. pylab and FlowCytometryTools rely on the other three, and any one of scipy, matplotlib or numpy brings in py2app recipies for the other two. One of these recipies isn't working with the xib, but I don't know why...
No experience with py2app, but I am wondering if you tried generating a more minimal version of the code that would fail to aid troubleshooting?
Maybe having FlowMac.py include nothing but the import statements:
import Cocoa
import Foundation
import AppKit
import FlowCytometryTools
import pylab
Also could you narrow it down to whether the problem appears due to pylab or due to FlowCytometryTools? (By commenting them out individually?)
From my testing, this error seems to be caused by the log output itself from py2app. Try redirecting standard error to a file:
python setup.py py2app 2>error_log
This should work around the error.