Command line to run a program with both xlwt and abaqusConstants modules - xlrd

Windows Machine, Python 2.4.
I have a program that imports both xlwt/xlrd and abaqusConstants module.
When I run my program with the command line: abaqus python abc.py, I get "ImportError: No module named xlwt/xlrd"
When I run my program with the command line: c:\python24\python.exe abc.py, I get "ImportError: No module named abaqusConstants".
The program ran perfectly when I ran it on my system where xlrd/xlwt was present in c:\python24\lib and Abaqus was installed in C-drive. When I tried to access xlrd/xlwt from my organisation's common share, the above problem appeared.
Is it because Abaqus is not present in the common share? How do I rectify this issue? Please tell me what command line to use.

the module abaqusConstants is only available in abaqus kernel executions of python so you need to be running it with abaqus python. Make sure that your PYTHONPATH variable is set properly to include the directory where xlwt/xlrd exists. see Using matplotlib (for python 2.6) with Abaqus 6.12 for a similar issue.

Related

Running remote Pycharm interpreter with tensorflow and cuda (with module load)

I am using a remote computer in order to run my program on its GPU. My program contains some code with tensorflow functions, and for easier debugging with Pycharm I would like to connect via ssh with remote interpreter to the computer with the GPU. This part can be done easily since Pycharm has this option so I can connect there. However, tensorflow is not loaded automatically so I get import error.
Note that in our institution, we run module load cuda/10.0 and module load tensorflow/1.14.0 each time the computer is loaded. Now this part is the tricky one. Opening a remote terminal creates another session which is not related to the remote interpreter session so it's not affecting remote interpreter modules.
I know that module load in general configures env, however I am not sure how can I export the environment variables to Pycharm's environment variables that are configured before a run.
Any help would be appreciated. Thanks in advance.
The workaround after all was relatively simple: first, I have installed the EnvFile plugin, as it was explained here: https://stackoverflow.com/a/42708476/13236698
Them I created an .env file with a quick script on python, extracting all environment variables and their values from os.environ and wrote them to a file in the following format: <env_variable>=<variable_value>, and saved the file with .env extension. Then I loaded it to PyCharm, and voila - all tensorflow modules were loaded fine.

Pandas Import Error when converting Python script to .exe with Pyinstaller

I am currently trying to convert my Python script that automates an Excel task for my boss to an executable so that I can send it to him and he can use it without having Python installed. One of the libraries I used in the script is Pandas, and when I run the .exe after successfully building it, I get "failed to execute script 'main' due to unhandled exception: No module named pandas."
This is what I used to build the .exe:
pyinstaller --onefile -w main.py
Obviously I have Pandas installed on my machine and the script works perfectly fine when I run it normally, so I don't really know why I am getting this error especially since I thought the whole point of me converting the script to an executable was to get rid of the need for other packages to be installed.
I have read other articles on here about a similar error relating to numpy, but none of the other solutions have helped me. I have tried doing --hidden-import pandas while building the executable and downgrading pandas to an older version, both to no success.
Any suggestions with help!

Tensorflow Object Detection API - PYTHONPATH unsets itself, when using different terminal

This might be a silly question, but I didn't find anything on the internet. I am trying to run the object_detection API of tensorflow in Windows 10. I've installed all the packages correctly and I've also added the "models" directory to the PYTHONPATH, using windows cmd:
set PYTHONPATH=C:\Program Files\Tensorflow\models
And I also verify that the PYTHONPATH is set correctly, by typing set PYTHONPATH, which gives me this output:
PYTHONPATH=C:\Program Files\Tensorflow\models
Running the following test
python research/object_detection/builders/model_builder_tf2_test.py
I get the output:
Ran 20 tests in 37.331s
OK (Skipped 1)
Which is great. However, If I open another terminal and type
python research/object_detection/builders/model_builder_tf2_test.py
I get the error: ModuleNotFoundError: No Module named official
However, If i type set PYTHONPATH command to verify that the PYTHONPATH is correct I get:
PYTHONPATH=C:\Users\Kohli\AppData\Local\Programs\Python\Python37\Scripts\Tensorflow\models;C:\Users\Kohli\AppData\Local\Programs\Python\Python37\Scripts\Tensorflow\models\official;C:\Users\Kohli\AppData\Local\Programs\Python\Python37\Scripts\Tensorflow\models\research
which is different from the previous terminal output. Moreover, when I open the "Enviroment Variables" tab, I can see that PYTHONPATH exists.
If I add the models directory to PYTHONPATH once again, It will work, but Only for that particular terminal. However, I don't understand why this is happening. Does the "set PYTHONPATH" command creates a virtual environment for that particular terminal or something? How can i permanently add models dir to PYTHONPATH, without typing set PYTHONPATH or os.path.append('path/to/models') ?
Thanks in advance

Pycharm giving error on a script which is working from terminal (Module: Tensorflow)

I was working with the tensorflow(GPU version) module in Pycharm. If I run a script from terminal, it works as expected. However when I run the script from pycharm, it says:
ImportError: libcudart.so.7.5: cannot open shared object file: No
such file or directory
How do I resolve this?
Pycharm interpreter shows tensorflow as a package.
In the terminal, when I check for the version of tensorflow, it was the same as in pycharm (0.10.0rc0)
Looks like your CUDA_HOME or LD_LIBRARY_PATH configured correctly in the console, but not in PyCharm. You can check and compare their values, in console do
echo $CUDA_HOME
echo $LD_LIBRARY_PATH
In PyCharm (say, in your main script):
import os
print(os.environ.get('CUDA_HOME'))
print(os.environ.get('LD_LIBRARY_PATH'))
You can configure them for the given Run Configuration in Environment Variables section.
Better approach would be configuring those environment variables globally, so every process in the system would have an access to them. To do that you have to edit /etc/environment file and add original values, which you got from console.
Here are very similar problems: one, two, three.

PyQt5 - pyuic5 module PyQt5.uic not found

I've upgraded my deveolpment environment from python-3.2/ Qt-4.8/ PyQt4 to python 3.4.2 / Qt5.3 / PyQt5.
Everything is Ok but the python source code generation with pyuic5.
When calling this commands I get the error
/usr/bin/python3: No module named uic
The Qt uic program is located at
~/Qt/5.3/gcc_64/bin/uic
The PyQt5 pacjakge is located at
/usr/local/lib/python3.4/site-packages/PyQt5
Even if the PyQt5 environment is operational as runtime I can't build any new GUI interface, so I can't move forward with this application upgrade.
Any idea ?
Thanks for help.
Thanks for the answer from #Akhil. The code below really helps me avoid the "module not found" problem, and successfully create a .py file from a .ui file.
exec python -m PyQt5.uic.pyuic youruifile -o yourpyfile -x
call python -m PyQt5.uic.pyuic -x filename.ui -o filename.py
this one worked for me (28th june 2017, PyQt5, python 3.6, win10, 64bit)
I faced the same issue. I had installed PyQt into a virtual environment and the issue was the the pyuic5 script was not using the python interpreter for that virtual environment.
So I opened up the pyuic5 script
exec pythonw2.7 -m PyQt5.uic.pyuic ${1+"$#"}
to
exec python -m PyQt5.uic.pyuic ${1+"$#"}'
This resolved the issue for me.
I know this is late, but I just recently encountered this issue when setting up external tools for Qt Creator. I know its not exactly what you ran into but it produces the same error. I don't like the idea of modifying files in my anaconda/bin directory so I didn't want to implement either of the other answers.
What I did find is that when you are setting up an external tool Qt Creator operates as if you are working in a new environment (i.e. your PATH is not the same as your development path). What I found is that you need to set the Environment field to have the same path as your development environment. This occurs by default when you setup Build and Run Settings for your project, but not for external tools.
Like #ekhumoro said in his comment You must pay attention to your PATH at all times.
I believe you are a Mac user and I had faced a similar issue.
It seems you'll simply have to provide the full path of the pyuic file (for me, it was under a hidden folder usr in the home directory: /usr/local/Cellar/pyqt/5.10.1_1/bin/pyuic5).
In your terminal, change directory to where the *.ui files( which you wish to convert to a *.py file) lies.
So for instance, if you have a Qt designer file saved by the name untitled.ui on your desktop, put in the following command in your terminal:
Amars-MacBook-Pro:Desktop amaradak$ /usr/local/Cellar/pyqt/5.10.1_1/bin/pyuic5 -x untitled.ui -o untitled.py
Hope this helps...
Cheers
Try this: i've been searching for 2 days and all problem solved!
First Rule in Python: Don't use .XML this is not Java instead use .PY for me i don't need uic at all
Let's begin, my pyuic5 actually there is no in PyQt5 folder instead in Scripts Folder
C:\......Python\Python37-32\Scripts\pyuic5.exe
you have to make sure that the yourFile.ui is in the same location of your pyuic5.exe
Follow the pict below, you will be understand:
How to convert ui to py for easy way
uic not found solved
it works like a Charm !
Hi everybody , see last pict, i just converted ui to py for the first time in my life !