When using ironpython in vb.net i am calling a python script. That script needs to import some packages (for example import html2text at the top of the script). On this machine i have python and pip and I have the package installed, but when running this script through ironpython it says it is unable to find it (no module named html2text).
So, when using ironpython, where does it look for the packages? how do I install these packages?
Related
I'm installing a package (cx_Oracle), and the documentation says:
Make sure you are not using the bundled Python. This has restricted
entitlements and will fail to load Oracle client libraries.
I'm wondering: how do I tell if my Python installation (if I did not install it) is "bundled" or not?
Normally in MAC OS python comes along with installation of OS itself that means python package included in OS files also called as bundled python. You can check if the python you are using is bundled or not by
which python
On mac os
you should get output like if it's a bundled python
/usr/bin/python
when you want to get the path of externally installed python by
which python3
The only difference is
When you type
python
in terminal it launches pre-installed or bundled python.
If you type
python3
in terminal it launches externally installed python in this cases what the oracle documentation is recommended
I'm using software that is built for Windows with no version for Linux. They have dedicated Python library called ArcPy, that has scripts of all of the tools available in this software.
On Ubuntu 16.04 I'm trying to import this package to my Python, so I can use all those scripts. Inside /usr/local/lib/python2.7/site-packages I created Desktop.pth into which I echoed:
/media/adam/somedisk/Program\ Files\ \(x86\)/ArcGIS/Desktop10.5/bin
/media/adam/somedisk/Program\ Files\ \(x86\)/ArcGIS/Desktop10.5/arcpy
/media/adam/somedisk/Program\ Files\ \(x86\)/ArcGIS/Desktop10.5/ArcToolBox/Scripts
Now entering Python shell and typing import arcpy returns ImportError: No module named arcpy. I know I typed the paths with correct escaping, because I can cd them.
Is it a correct way of importing Python packages across OSs? What went wrong here?
You can not use arcpy unless, either ArcGIS Server or ArcGIS engine is installed in the machine. ArcPy does not work without the binaries.
I'm trying to run a script that was written with python 2.7, using some libraries that I've installed on my Windows machine - among them numpy scipy, scikit, requests and others.
Now I need to use a COM object dll, so I am writing an IronPython script that loads that dll. However when I try to use or import the python 2.7 code, I get import errors:
ImportError: No module named requests
How can I use that python 2.7 code I wrote with IronPython? I could run the script with the python 2.7 interpreter through a system command, but that would mean a big waste of time.
Any help would be appreciated.
IronPython is written in C#, so you can't (easily) use C Extensions for cPython on it.
There is a port of numpy and scipy for the Microsoft .Net environment.
For pure python packages and modules, appending to sys.path allows you to do imports.
Did you python setup.py install your own code? Otherwise it won't be in the installations site-packages and you should add your project's directory to sys.path.
There is an additional problem with requests, an issue with supported encodings (https://ironpython.codeplex.com/workitem/4565) prevents that from working. The issue has been open for ages.
If you can be more specific about your code and setup, other people could chime in with more suggestions.
I am attempting to install IronPython. I downloaded the stable 2.7.5 installer from here:
http://ironpython.net/download/
I ran the installer and all is well. It is not located at:
C:\Program Files (x86)\IronPython 2.7
I have a previous installation of Python 2.7 from my ArcGIS installation, which packages and installs python along with it. My installation location for python is:
C:\Python27\ArcGIS10.2
So, when I test and:
import clr
I receive and error:
ImportError: No module named clr
My Environment Variable Path names are all correct.
I'm just wondering if python IDLE knows where to grab IronPython, or did I install wrong?
The name of the IronPython intepreter is ipy.exe. If you not starting this, you are not using IronPython. So you should see the application name in the window title and when starting the shell. When you use it in an IDE, you should tell the IDE that you are using IronPython, if it support it. Just setting some environment variables will not help. If you are targeting the correct directory and ipy.exe will be used, everything should work just fine.
I am fairly new to Python and trying to install the Pillow package on Windows 7. I downloaded and ran the MS Windows installer Pillow-2.2.1.win-amd64-py3.3.exe from here. It appeared to install fine. If I run the simple line of code:
from PIL import Image
directly from the Python interpreter, it runs fine. A help() on PIL gives me the package contents.
But when I try to run the same line of code from within a script, I get an ImportError: No module named PIL. What am I missing?
(Note that I've been able to import sys and import MySQLdb from within scripts just fine.)
Resolved: sure, enough, I'm running Python 2.7 when I run scripts. (I think I vaguely recall having to install an older version so I could interface with MySQL.) Thank you all for pointing out that I should check the version being used.
For third-party modules for Windows, my go-to resource is Christoph Gohlke's Python Extension Packages for Windows. You can find the latest version of Pillow here. Make sure you're working with the python.org version of Python.
As far as your specific error, it's hard to tell exactly without a traceback, but make sure your script is calling the correct version of Python. If you have also installed Python 2.7, for example, your script may be calling that instead of 3.3.
In such cases I'm simply printing the sys.path at the beginning of the script in trouble and comparing it with the one from the working python interpreter. In most cases I was running the script with a different python interpreter.
In my case , I was referring to wrong pip folder.
Changed virtual environment in pycharm to point to right pip folder to solve this issue
import sys
print ( sys.path )