How to fix 'zsh: command not found: pytest'? - pytest

I have python3 and pip3 installed. I also install pytest but when I enter the command pytest, it does not work. It shows me the following:
<zsh: command not found: pytest>
How do I fix this please?

You need to specify the location of the pytest executable—the program that executes pytest—to your computer in order to use the pytest command.
You can do this by adding the directory path where the pytest executable is located to your computer's list of locations it should search for applications.
The PATH environment variable is the name given to this list.
You may use your computer's settings to update the PATH environment variable or you can execute a program in the terminal to add the path of the directory containing the pytest executable to it.
Your computer should then will be able to locate and launch pytest once the PATH environment variable has the path to the directory containing the pytest executable.

Related

How to fix diesel_cli link libpq.lib error with Postgres tools installed in Docker?

I'm trying (for hours now) to install the cargo crate diesel_cli for postgres. However, every time I run the recommended cargo command:
cargo install diesel_cli --no-default-features --features postgres
I wait a few minutes just to see the same build fail with this message:
note: LINK : fatal error LNK1181: cannot open input file 'libpq.lib'
error: aborting due to previous error
error: failed to compile `diesel_cli v1.4.1`, intermediate artifacts can be found at `C:\Users\<user name here>\AppData\Local\Temp\cargo-installUU2DtT`
Caused by:
could not compile `diesel_cli`.
I'm running postgres in a docker container and have the binaries on my C:\pgsql with the lib and bin directories both on the PATH so I can't figure out why it's not linking. What else could be required they didn't mention in the docs?
In my case the installation was successful but when I tried to run it this error occured.
maybe this would work for others who have the same problem:
open PowerShell
type in setx PQ_LIB_DIR "C:\Program Files\PostgreSQL\13\lib" (or any other path to your PostgreSQL lib)
restart your PC
run again
I had the same issue with WSL, if you're on Linux probably you could find PostgreSQL lib location and add it to your environment variables.
Update:
The answer below is a work around for older versions. Please check the possibility to execute cargo clean first
Original Version
Adding the folder to the PATH variable didn't help, at least in my case, as by some reason it is not used in the /LIBPATH parameter passed to link.exe.
In my case it was C:\Users\<username>\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib
You can see it in the beginning of the error message.
Copy libpq.lib in there and it will be used from there.
After installation diesel would require some other assemblies. Copy libcrypto-1_1-x64.dll, libiconv-2.dll and libssl-1_1-x64.dll into the folder showed after where diesel command execution
I had the same error on Ubuntu and for me the following install fixed the issue:
sudo apt install libpq-dev
No need to move files around, just add C:\Program Files\PostgreSQL\14\lib and C:\Program Files\PostgreSQL\14\bin to your PATH. Installing and running diesel should have no problems.
Note: your paths may be different, and remember to close/reopen your terminal so the PATH variable is updated.
(Tested on Windows 10)
To give clear steps for windows:
Add C:\Users<username>.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib in the path in environment variables
Copy libpq.lib that is in C:\Program Files\PostgreSQL\14\lib (obviously this is with version 14) and paste it in C:\Users<username>.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib
If you've attempted to cargo build (or anything that runs the build scripts for libpq rust crate) when your environment was invalid, then you need to do a cargo clean after fixing your environment otherwise you'll still get the libpq.lib not found error even when it's in your PATH. The other answers where you copy the file into another directory are just hacks
You can instead add the path to .../lib to the compilers' library search paths, using RUSTFLAGS environment variable. It works both for installing diesel_cli and for building your projects.
RUSTFLAGS='-L /usr/local/pgsql/lib' cargo build
On Windows with EDB installer, the path contains a space, so use CARGO_ENCODED_RUSTFLAGS instead. For PowerShell:
$env:CARGO_ENCODED_RUSTFLAGS = "-L`u{1f}C:\Program Files\PostgreSQL\14\lib"

Unable to import matlab.engine in python

import matlab.engine
In my case, with MATLAB R2014a, I got the following error message:
ModuleNotFoundError: No module named 'matlab'
and this path "matlabroot\extern\engines\python" is not present
"matlabroot" is not part of the path name. It needs to be replaced with the name of the MATLAB root directory. Typically that's, "C:\Program Files\MATLAB\20???"
Where ??? is replaced by your MATLAB version number.
So, open the command prompt with administrative privileges.
cd "C:\Program Files\MATLAB\2014a\extern\engines\python"
python setup.py install
If you don't have admin privileges, you can use this command to name alternative directories for setup.py to use:
python setup.py build --build-base="builddir" install --prefix="installdir"
Good luck!

pyrcc5: No such file or directory

I want to install labelImg for mac OS in python 3.7. here is the repo: https://github.com/tzutalin/labelImg
I have installed previous modules via 'pip3 install pyqt5 lxml' successfully. Cloned the repo, entered the folder 'labelImg', but only 'make qt5py3' does not work..
but when I execute 'make qt5py3', i get the error
pyrcc5 -o libs/resources.py resources.qrc
make: pyrcc5: No such file or directory
make: *** [qt5py3] Error 1
What can I do here? What might have caused the issue?
-find 'pyrcc5' under python bin, and copy 'path'
-under labelImg find 'Makefile' and edit
-change line
qt5py3: pyrcc5 to qt5py3: 'copied path'/pyrcc5
and save
-and
make qt5py3
python labelImg.py
should works.
I had the same issues as the OP, but with Python 3.6.11. In addition, I got ModuleNotFoundErrors for pyqt5 and libxml2, even though brew confirmed they were both installed. Also, I was trying to install in a virtual environment set up using pyenv.
What finally worked for me was:
1) use global env, not virtual
2) use pip (not pip3) to install pyqt5 and lxml
3) change the makefile as #zippo suggested
After I did that, I was able to get labelImg to start by running:
python labelImg.py

sbt command not found

I am installing sbt in my cloudera distribution.
I have downloaded sbt.0.13.15
Moved file to /usr/local
Then I had updated profile
sudo nano profile
Added export PATH=$PATH:/usr/local/sbt/bin
Saved file and exited.
But now if I issue "sbt about" command, I am getting sbt: command not found.
Could you please help to resolve this issue.
Some suggestions:
Check your PATH variable: echo $PATH
The PATH variable is not updated automatically by writing into .profile, either open a new shell or do source .profile
The file is called .profile, not profile

Issue with dependencies running python file on another PC

I have a python file running perfectly in the IDE.
I want to run it on a different PC without any IDE.
I run the program from the command line: python program.py
Error message: File "program.py", line 8, in
from mpl_finance import candlestick_ohlc
ModuleNotFoundError: No module named 'mpl_finance'
When trying: pip install mpl_finance (or pip install mpl_toolkits)
I get the message: No matching distribution found for mpl_finance (or mpl_toolkits)
There also seems to be a problem with matplotlib backend.
Looking for a solution please.
After many failed paths, here's what worked:
matplotlib.finance is deprecated and it is now mpl_finance.
Create 2 files named mpl_finance.py and setup.py and get their contents from here.
Then from the command-line: python setup.py install
Fixing the backend (this can save you a few days):
If the backend of matplotlib was set in a file original PC (and not in the code). Then you need to do the same on the second PC.
Windows Path: C:\Program Files\Python36\Lib\site-packages\matplotlib\mpl-data\matplotlibrc
Change (probably line 38) to this: backend : Qt5Agg