Python behave running from python2.7 rather than python3.4 - python-behave

When I run behave it seems to run from python2.7 and fails to find selenium, which is installed for python3.4. Do I need to configure behave to run python3.4 somewhere - I can see nothing on the behave site, or elsewhere. There are posts about using behave with python 3.4, so it is possible.
Here is what I see:
$ behave
...
File "/usr/local/lib/python2.7/dist-packages/behave/runner.py", line 304, in exec_file
exec(code, globals, locals)
File "features/steps/home_page.py", line 2, in <module>
from selenium import webdriver
ImportError: No module named selenium
I have PYTHONPATH pointing to python 3.4/dist-packages:
$ echo $PYTHONPATH
/usr/local/lib/python3.4/dist-packages
$ ls /usr/local/lib/python3.4/dist-packages/selenium
common __init__.py __pycache__ selenium.py webdriver
I have behave installed in both /usr/local/lib/pythonX.X/dist-packages where X.X is 2.7 and 3.4
Any help much appreciated.

If you install behave for Python 3.x and Python 2.7 each installation will install the script that starts Behave at the /usr/local/bin/behave location. Whichever is installed last will win the conflict because it will overwrite the other's file. (The files that go in /usr/local/lib/python<version>/dist-packages will be fine because <version> is different in each case.)
One way to fix this is to settle on installing Behave only on Python 3. Uninstall the Python 2.7 version and reinstall the Python 3 version, and it should work.
If you do need both versions for different projects then you should use virtualenv to create Python installations for the various projects you are working on. This is what I've settled on for my own projects.

Related

lmfit packages conflicting in Windows 10 using Anaconda Python 3.7

I'm trying to use a curve fitting package (lmfit) I did use several times in former times with Python 2.7. Since I moved to Python 3.7, I'm facing some problems on running my script. The error message I get is "ModuleNotFoundError: No module named 'lmfit'".
If I try to reinstall/update the package (using whatever of the commands in https://anaconda.org/conda-forge/lmfit): it looks like there are conflicting packages in my pc. Here the screen of my prompt:
prompt after using 'conda install -c conda-forge/label/cf202003 lmfit'
Any hints on how to solve this conflict?
just install with pip install lmfit.

Terminal issues error message that no Django module "models" exists, but it is in the directory

I'm a motivated beginner working my way through Python Crash Course. I created a project and an app using Django. I'm unable to get the python manage.py run server command to work. This is the header of the long error message:
"Watching for file changes with StatReloader
Exception in thread Django-main-thread".
The middle includes several lines of "".
At the end, it says "from models import Activity"
"ModuleNotFoundError: No module named 'models''
There IS a module named models in the directory. This is my second exercise using Django, and the program worked earlier. I've searched the net and read everything remotely similar, but have been unable to find a solution. How can I make the program recognize a module that is there?
I think the problem was that the version of pip in the virtual environment was the python 2.7 version instead of the 3.9 version I used to create the project. It had to be upgraded using:
python3 -m pip install --upgrade pip
I also used python3 for the manage.py runserver command instead of just python.

tcms-api 5.3 package incompatible with Windows

I attempted to upgrade my tcms-api library from 5.0 to 5.3 using:
pip install tcms-api --upgrade
on a Windows 10 machine, I saw a lot of errors when trying to install the dependent package of kerberos. Even though this is old, I saw a similar set of errors. The package installation failed since the kerberos package isn't supported on Windows and I was left at tcms-api 5.0.
Please file a bug against https://github.com/kiwitcms/tcms-api.
We can do a quick fix by providing 2 package names:
tcms-api and tcms-api[kerberos]
The first one will not install the kerberos package.
The proposed workaround makes sense but changing the underlying kerberos implementation needs careful testing which isn't a quick job.
OTOH https://github.com/kiwitcms/python-social-auth-kerberos uses gssapi which seems to be the latest and most actively maintained implementation of Kerberos for Python. There is an open issue to migrate to that in tcms-api so you can contribute if you want.
As a workaround, I was able to do the following (caveat: I haven't extensively tested my installation yet):
Clone the tcms-api repo from GitHub
Edit setup.py to change the install_requires line to use 'kerberos-sspi' rather than 'kerberos'
Install the following pip packages: Setuptools, Wheel, Twine
CD to repo folder and run: python setup.py bdist_wheel
That creates a package under the dist folder
Run pip install dist\tcms_api-5.3-py3-none-any.whl
Celebrate successful package install
The steps were modified from this page.
Update:
I confirmed the things I need the API to do work with my custom package (create and update test runs). However, I'm in a situation where I don't need to specifically harden my Kiwi instance using kerberos authentication.

Where does sdkman install packages?

I used sdkman to install groovy which went fine. Where is the installed package now? I need the path for it. I am on Ubuntu 14.04.
I've checked it on my system. It should be located in $HOME/.sdkman/candidates/.
I think the best way would be to use SDKMan's home command:
https://sdkman.io/usage#home
Something like this (taken from the above page):
$ sdk home java 11.0.7.hs-adpt
/home/somedude/.sdkman/candidates/java/11.0.7.hs-adpt
Upon installation, SDKMAN creates an environment variable $SDKMAN_DIR which points to the installation directory.
Usuall it's ~/.sdkman
After you have run source $HOME/.sdkman/bin/sdkman-init.sh.
You can see the sdkman "installation" by running:
declare -f
$HOME on mac is /Users/<users>
Where's SDKMan installed:
echo #SDKMAN_DIR
Where did it just install gradle? (or some other package)
which gradle
SDKMAN stores file in $HOME/.sdkman/candidates/ as Tom mentioned and this answer goes into more detail.
To find where SBT 1.3.13 is installed, type sdk home sbt 1.3.13. It'll return something like /Users/powers/.sdkman/candidates/sbt/1.3.13.
The arguments to the sdk install command align with where the files are stored in $HOME/.sdkman/candidates.
sdk install java 8.0.272.hs-adpt stores files in $HOME/.sdkman/candidates/java/8.0.272.hs-adpt.
sdk install sbt 1.3.13 stores files in $HOME/.sdkman/candidates/sbt/1.3.13.
When you run sdk install, the downloaded binaries get saved in $HOME/.sdkman/archives. For example, $HOME/.sdkman/archives/java-8.0.272.hs-adpt.zip and $HOME/.sdkman/archives/sbt-1.3.13.zip.
Some of the binaries are pretty big and can end up taking a lot of space on your computer. You should periodically delete them with the sdk flush archives command. Once you install the software, you don't need the binaries anymore. See here for more details.

What are dronekit-python dependencies?

The dronekit Getting Started page suggests installing WinPython to use dronekit-Python on Windows because it includes the dependencies. I already have a working Python installation and I prefer not to risk messing it up with WinPython. What are the dependencies I need to install?
As of DKPY 2.0 this is outdated. Also, I might move to making a MavProxy module depending on whether or not the unpaid devs decide to stay when 3DR stops funding Dronekit
I've written a procedure to help with this problem which I've pasted. 3DR claims they're going to fix it, but in the mean time I hope this will help.
This setup is for Windows 64-bit systems only, although similar procedures will work with 32-bit.
Install MAVProxy and run it once before reaching step 5.
Install Notepad++.
Install Python v2.7.
Inside the Python folder, run WinPython Control Panel and select Advanced->Register Python.
Inside the same folder, run WinPython Command Prompt and input the following four commands:
• pip uninstall python-dateutil
• pip install droneapi
• pip install console
• echo module load droneapi.module.api >> %HOMEPATH%\AppData\Local\MAVProxy\mavinit.scr
Install WX Python. It should be the 64-bit Python 2.7 version.
Download and install OpenCV 2.4.11 to any folder
• Copy/paste the file cv2.pyd from OpenCV\build\python\2.7\x64\ to \python-2.7.6.amd64\Lib\site-packages.
Steps 8 through 11 apply to SITL only
Follow the online documentation for setting up Cygwin for SITL in Windows
Go to C:\cygwin\home\Your Username\ardupilot\Tools\autotest\
Open sim_vehicle.sh in Notepad++
• Change line 429 from…
cygstart -w "/cygdrive/c/Program Files (x86)/MAVProxy/mavproxy.exe" $options --cmd="$extra_cmd" $*
to...
cygstart -w "/cygdrive/c/Users/YOUR USERNAME HERE/Desktop/WinPython-64bit-2.7.6.4/python-2.7.6.amd64/Dronekit/Scripts/mavproxy.py" $options --cmd="$extra_cmd" $*
Note: This location changes depending on where you installed WinPython. For me, it was the desktop.
Start simulations as you would normally for SITL. To run Python scripts during the simulations, use the command
• api start Path to script\script_name
To use the code to connect to an actual copter, open WinPython Command Prompt
• Navigate to the folder which contains the scripts you wish to test
• Type mavproxy.py --master=”com##”,57600
• Run your script by typing into the MAVProxy terminal
o api start script_name

Resources