No Module After Install Package via Canopy Package Management - python

I need help with the pyodbc Python module. I installed it via Canopy package management, but when I try to import it, I get an error (no module named pyodbc). Why?
Here's the output from my Python interpreter:
import pyodbc
Traceback (most recent call last):
File "", line 1, in
import pyodbc
ImportError: No module named 'pyodbc

For the record: the attempted import was in a different Python installation. It is never good, and usually impossible, to use a package which was installed into one Python installation, in another Python installation.

Related

Not able to import module after installing using pip

Im trying to import a module called geoip2 from pypi into python it is not included in its standard libraries.
I open command prompt and type:
pip install geoip2
The command prompt returns
Successfully installed geoip2-2.4.2
After it is installed I try importing it using IDLE:
import geoip2.webservice
which returns the error:
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import geoip2.webservice
ImportError: No module named 'geoip2'
Although it is installed already I cannot use it. How can i prevent this? Take note that I use python 3.6
May be you have two different version of Python installed. Try opening IDLE using the Python version where you have installed geoip.
Instead of:
import geoip2.webservice
Try doing:
import geoip2
from geoip2 import webservice
Since geoip2.webservice is not installed, geopip2 is and .webservice is an function object of that module.
Further, you can avoid typing geoip2.webservice every time by doing:
import geoip2
from geoip2 import webservice as gws
Then anytime you want to run the .webservice function, you can just use gws.
Alternatively:
Just do:
import geoip2
Then in your script you can call it:
geoip2.webservice(#do stuff here or however you call the function)

Python third party Module global import

i'm currently into learning a bit of python and i want to import the paperclip third party module into my python file.
Yes, i already installed the pyperclip module with
pip install pyperclip.
if i create a file on my desktop, i get an error which says
Traceback (most recent call last):
File "test.py", line 1, in <module>
import pyperclip
ImportError: No module named pyperclip
However if i put the test.py in my python folder, it runs.
The question now is, is there a way to make all my installed modules available on a global scope ? I just want to have my file e.g. on my Desktop and run it without having import issues.
Thank you.
Greetings
Edit: I'm working on a Mac, maybe this leads to the problem
Found the problem.
The pip installautomatically used pip3.5 install
whereas python test.pydidn't use python3.5 test.py
Thank you #Bakurìu
Is there a way i can define python3.5as python?
You can do this :
pip3.5 install paperclip
pyperclip is install but not paperclip

Python script can't find pymongo module - Mac

so I was trying to run a python code, but the shell kept telling me that no 'pymongo' module was found.
Now, I have python 3.5.1 installed.
when I run pip freeze | grep pymongo it returns pymongo == 3.2.2 so it's clearly installed. I tried to run pymongo from the shell rather than a script but I get the same error every time.
import pymongo
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named 'pymongo'
So, help? It worked fine a month ago or so..
It means PyMonogo module is not installed for your Python 3. In the shell you can check the installed modules for your python.
import pip
pip.get_installed_distributions()
Check if pymongo is listed there. You have to install pymongo for python 3.

Error during library import in Python (Windows)

I am trying to configure svn hook for email notification using mailer.py script from apache, but it always crash on import of svn libs. I try two ways of installing svn and python. I try to install everything manually using command line and use CollableNet installer that have preinstalled Python and all libs I need but result is the same.
Now I try to import one library from hole package that I need using python in command line and I have such response:
>>> import svn.core
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named svn.core
I try to fix it using:
1) import sys; sys.path.append("C:\csvn\lib\svn-python\svn")
and
2) C:\csvn\lib\svn-python\svn>python "\__init__.py" install
But it didn't help.
For now I have no package with setup.py to install it.
I spend a lot of time on this task, and going crazy a little). Please give me any suggestion how to fix it.

Python - cannot import slycot module in spyder (RuntimeError & ImportError)

When I try to import the slycot module in spyder (version 2.2), I get the following error:
RuntimeError: module compiled against API version 7 but this version of numpy is 6
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Applications/Spyder.app/Contents/Resources/lib/python2.7/slycot/__init__.py",
line 4, in <module>
from slycot.analysis import ab01nd,ab05md,ab05nd,ab07nd,ab08nd, ab09ad
File "/Applications/Spyder.app/Contents/Resources/lib/python2.7/slycot/analysis.py",
line 21, in <module>
from slycot import _wrapper
ImportError: numpy.core.multiarray failed to import
Now, when I import slycot in the python shell through my terminal, there are no problems at all. I think the reason why there are no problems through the terminal, is that I recently installed numpy 1.7.1. Spyder on the other hand still uses numpy 1.6.2.,hence the error.
I tried to change the numpy version in spyder, but so far that didn't work.
When I change the numpy(6) folder in my spyder lib with the recently installed numpy(7), I get the following error (in spyder):
ImportError: Error importing numpy: you should not try to import numpy from
its source directory; please exit the numpy source tree, and relaunch
your python intepreter from there.
What is the best way to solve this error?
Thanks in advance.
(Spyder dev here) At the moment it's not possible for the user to install anything inside the app. I guess you moved your slycot module from another interpreter to our App (because of the numpy error you mention).
The right way to use different modules not present in the app, is to change the path of your interpreter in:
Tools > Preferences > Console > Advanced settings > Python executable
If you installed slycot using your system Python, you have to select
/usr/bin/python

Categories

Resources