I have successfully installed DiffSharp (along with TorchSharp, Libsharp etc.), using the following F# script:
#r "nuget: DiffSharp.Core"
#r "nuget: DiffSharp.Backends.Reference"
#r "nuget: DiffSharp.Data"
#r "nuget: DiffSharp.Backends.Torch"
#r "nuget: TorchSharp"
#r "nuget: LibTorchSharp"
open System
open DiffSharp
open DiffSharp.Data
open DiffSharp.Model
open DiffSharp.Compose
open DiffSharp.Util
open DiffSharp.Optim
The following functions however, are not available (which should be, according to the DiffSharp API reference):
dsharp.config(backend=Backend.Torch, device=Device.CPU)
dsharp.seed(1)
let x = dsharp.randn([1024; 5])
Any ideas why? Am I missing any library or open statement?
I'm not sure why this is not working, but the DiffSharp installation isntructions recommend using the DiffSharp-cpu package (or one for cuda or lite version if you have LibTorch already) and that works fine for me:
#r "nuget: DiffSharp-cpu"
open DiffSharp
dsharp.config(backend=Backend.Torch, device=Device.CPU)
dsharp.seed(1)
let x = dsharp.randn([1024; 5])
Produces:
val x: Tensor =
tensor([[-1.5256, -0.7502, -0.6540, -1.6095, -0.1002], ...])
Related
I am using robot framework with python. I am trying to get seleniumLibrary instance in python file using following code
from robot.libraries.BuiltIn import BuiltIn
class PythonDemo(object):
def __init__(self):
self.myInstance = BuiltIn().get_library_instance('SeleniumLibrary')
When i try use self.myInstance to populate keywords, its not showing in .py file.
In .robot file, i can easily access robot and seleniumLibrary keywords. But unable to use seleniumLibrary instance in .python file
Below are configuration details-
Pycharm community edition 2020.3
robotframework 3.2.2,
robotframework-pythonlibcore 2.1.0,
robotframework-ride 1.7.4.2,
robotframework-seleniumlibrary 3.3.1,
selenium 4.1.0,
python 3.8.0,
plugin - intellibot#seleniumLibrary Patched.
is there any setting in Pycharm? or am i missing anything?
Could anybody please help me with this issue?
Thanks
Not Possible - you will get RobotNotRunning exception if you just try to acquire "instance" of a library via BuiltIn() if the python code you have is executed directly and not by adding Library YourPythonCodeLib to settings section of the "your_test_or_task.robot".
I am a absolute beginner of python and working on a small program to collect data and write multiple sheets to Excel using pandas, it worked as expected. However after convert to exe file using pyinstaller, it only write first sheet. No matter in onefolder or onefile mode.
I pasted the minimum code that can recreate the problem.
I know I can just writer.save() once in the end but in real program I writer multiple sheets in for loop and it's a lot more efficient and create much smaller xlsx file than just save once in the end.
PyInstaller: 3.4
Python: 3.7.2
pandas: 0.24.2
Platform: Windows-10-10.0.17763-SP0
I search the problem everywhere, tried to use hiddenimports to add different modules for pyinstaller, like such:
hiddenimports=['pandas', 'pandas.io.excel', 'numpy', 'pandas.compat', 'xlsxwriter', 'openpyxl'],
None of them works.
import pandas as pd
writer = pd.ExcelWriter('xlstest.xlsx')
df1 = pd.DataFrame(data=[[1, 2, 3]], columns=("a", "b", "c"))
df2 = pd.DataFrame(data=[[5, 6, 7]], columns=("d", "e", "f"))
df1.to_excel(writer, sheet_name="sheet1", index=False)
writer.save()
df2.to_excel(writer, sheet_name="sheet2", index=False)
writer.save()
I solved my own problem. I was using Pycharm for the project. It appears that pycharm using a virtual environment while pyinstaller using the local system environment. So I tried to compare the installed packages in both environment and find out what could be the reason. I have same version of pandas and openpyxl installed in both environment, which puzzled me for a while. Tried a lot of things and eventually find out it was XlsxWriter package caused the problem. I have XlsxWriter 1.1.5 installed in local environment but not in pycharm venv. As soon as I pip uninstalled it from local env. My compiled exe file works correctly.
I am still looking into how to correctly using pyinstaller in pycharm venv. Any comment on that is welcomed.
Need example for install program (.exe) using subprocess module in python
I am using following code and got "[WinError 2] The system cannot find the file specified"
I verified The path and it is correct
iv_arg = [ r'C:\Users\shlomil\Desktop\Utilities_Installers_new\Programs\iview444_x64_setup.exe']
subprocess.run(iv_arg)
This works for me:
iv_arg = "C:\\Users\\shlomil\\Desktop\\Utilities_Installers_new\\Programs\\iview444_x64_setup.exe"
subprocess.run(iv_arg, shell=True)
I am working on Python 3.2.5 version and my requirement is to create and write to an excel file. I tried with xlsxwriter and xlwt both, but ended up in getting ImportError. I can't install these modules.
Any other module which does excel creation please?
I think your python excel lib are not yet contained in python library path.
Window:
C:\Python27\Lib\site-packages\XlsxWriter
In other platform, also you should try to put XlsxWriter library under site-packages. It can solve the ImportError.
My code is working fine when i run it with python but if i try to use py2exe or cxfreeze importlib module isn't working, and i've been looking for a while now to get it working..
heres the part of my code not working (im 99% sure its):
idm = cc.GetModule("idmantypeinfo.tlb")
name = str(idm)
module = name[9:65]
IDMan = importlib.import_module(module)
this works with python via console, but it instantly crash when compiled after it calls IDMan:
idm1 = cc.CreateObject("IDMan.CIDMLinkTransmitter", None, None, IDMan.ICIDMLinkTransmitter2)
this is because of that part :
module = name[9:65]
IDMan = importlib.import_module(module)
which should give me an object but after compiling with py2exe or cxfreeze (even pyinstaller) it just gives me a string because importlib isn't working i've no idea how to fix that..
Finally got it working with cx, i simply forgot to link the build options.. included comtypes & importlib, problem solved.