Apxs command showing up in Linux terminal but not Pycharm terminal - python-3.x

Currently moving all of my Pycharm Projects to Linux (Debian-based distro) and had a mod_wsgi dependency in one of my projects. So I get the following error.
RuntimeError: The 'apxs' command appears not to be installed or is not executable.
Please check the list of prerequisites in the documentation for this package and
install any missing Apache httpd server packages.
Ok, no problem, so I install apache.
sudo apt install apache2-dev
Testing in the global terminal, apxs appears.
tony#pop-os:~$ apxs
Usage: apxs -g [-S <var>=<val>] -n <modname>
apxs -q [-v] [-S <var>=<val>] [<query> ...]
apxs -c [-S <var>=<val>] [-o <dsofile>] [-D <name>[=<value>]]
[-I <incdir>] [-L <libdir>] [-l <libname>] [-Wc,<flags>]
[-Wl,<flags>] [-p] <files> ...
apxs -i [-S <var>=<val>] [-a] [-A] [-n <modname>] <dsofile> ...
apxs -e [-S <var>=<val>] [-a] [-A] [-n <modname>] <dsofile> ...
So I restart the machine, reopen Pycharm, and try installing the requirements again.
pip install -r requirements.txt
Next I proceeed to type 'apxs' in the Pycharm terminal:
(venv) apxs
sh: apxs: command not found
Strange, so then I check $PATH in Pycharm:
(venv) echo $PATH
/home/tony/PycharmProjects/FirstDjangoProject/venv/bin:/app/bin:/usr/bin
So, /usr/bin is where apxs is installed on the global terminal, but it isn't recognized in pycharm. Strange.
I then go take a peek in the /usr/bin dir
(venv) ls /usr/bin/ | grep apxs
(venv)
Strange. So certain files that show up in the global terminal (This applies with sudo as well) don't show up in the Pycharm terminal. Anyone know how to work around this?

Alright, so here's what happened:
I am using Pop!_os and installed the Pycharm Professional flatpak from the Pop!_Shop (Pop!_os' app store). It seems installing it using snap seemed to resolve the issue. Not only that, I had to completely rebuild my venv ask it said something like "Invalid SDK". I also noticed the shell settings, along with the Python version was different (3.7 on the flatpak whereas 3.8 on the snap install).
Lesson learned. Don't always rely on the Pop!_Shop

Related

How to change python3 to default in linux mint

I have a little problem with changing python3 to default in newly installed operating system linux Mint 19.3. It was pretty easy on Ubuntu 16.04 but now I need small help here.
So, I run
python --version
and got this
Python 2.7.15+
Than I run
python3 --version
and this was the result
Python 3.6.8
After entering this command
sudo update-alternatives --config python
I received obvious info
update-alternatives: error: no alternatives for python
Both version of python are located in /usr/bin folder.
The issue occurs when I'm trying to change python3 to as a default by typing the command
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6
The terminal outputs the following
update-alternatives: --install needs <link> <name> <path> <priority>
Any help here would be welcome.
In your case, priority is missing, just append 1 at the end of the command like this :
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 1
To define python3 as your default version of python on linux, you need to add a specific line to .bashrc file located in your home directory.
Here is a simple method to do so through command line interface (termianl).
Run:
$ echo "alias python='python3'" >> .bashrc
$ source .bashrc
then run python --version to check if the change has applied.
#darkfidis answer is correct. But you may also need to run to set or change the default python version.
sudo update-alternatives --config python

"You don't have [ ] in your PATH," but is in [echo $PATH] (Linux)

I am trying to install the github-pages ruby gem on Linux Mint for use with jekyll.
After running sudo gem install github-pages I get:
WARNING: You don't have /home/max/.gem/ruby/2.3.0/bin in your PATH,
gem executables will not run. Building native extensions. This could
take a while...
ERROR: Error installing github-pages: ERROR: Failed
to build gem native extension.
The curious thing is that my path, as printed by echo $PATH and by sudo echo $PATH both include
/home/max/.gem/ruby/2.3.0/bin
So how do I end up with that warning that it is not in my PATH?
Try:
sudo PATH=$PATH command
It is possible that sudo is scrubbing your path environment variable.
Also if you want to check the path that command with sudo sees run this instead, otherwise $PATH gets extrapolated by current shell.
sudo bash -c 'echo $PATH'

wmctrl not executable while running sikulix script in headless mode

I'm using Ubuntu 14.04 lts and sikulix 1.1.0.
while running sikulix script in the ordinary way it's working great, but when i'm trying to use Xvfb just like suggested here, it's says that there is no wmctrl installed. and thats not true, this is the output in shell:
running SikuliX: -Xmx512M -Dfile.encoding=UTF-8 -Dsikuli.FromCommandLine
-jar ./sikulix.jar -r ../sikuliscripts/script.sikuli
[info] runcmd: lsb_release -i -r -s
[error] RunTimeIDE: *** terminating: command 'wmctrl' is not executable
please check the Availability!
thanks in advance!
Try to install it by
sudo apt install wmctrl
happy sikuling!
It doesn't run because wmctrl expects a window manager.
Demostration:
$ wmctrl -m
Cannot get window manager info properties.
(_NET_SUPPORTING_WM_CHECK or _WIN_SUPPORTING_WM_CHECK)
Solution is simple:
$ yum instal icewm
$ icewm&
$ wmctrl -m
Name: IceWM 1.3.8 (Linux 4.3.0-1.fc24.x86_64/x86_64)
Class: N/A
PID: 15972
Window manager's "showing the desktop" mode: N/A
IceWM is a lightweight window manager.
Credits: thanks Ramandeep Singh for providing me the clue. :-)

pip with venv shows many modules installed

I built Python 3.3.0 from source on my Ubuntu 13.10 laptop.
When using the /usr/bin/virtualenv -p /python3.3.0/bin/python3 foo_virt command to create a virtual environemnt, I see no modules installed when running pip freeze, which is the behavior I expect.
When using /python3.3.0/bin/python3 -m venv foo_virt, I see tons of modules installed:
(foo_virt) user#laptop:/foo_virt$ /usr/bin/pip freeze --local
Jinja2==2.7
Mako==0.8.1
MarkupSafe==0.15
PAM==0.4.2
Pillow==2.0.0
Pygments==1.6
SecretStorage==1.0.0
... (total of 75 modules listed)
I tried then to install pip for that specific version of Python, by running, as per the module's documentation: python3 get-pip.py. But I still see all these modules:
(foo_virt) user#laptop:/foo_virt$ which pip
/foo_virt/bin/pip
(foo_virt) user#laptop:/foo_virt$ pip freeze --local
Jinja2==2.7
Mako==0.8.1
MarkupSafe==0.15
PAM==0.4.2
Pillow==2.0.0
Pygments==1.6
SecretStorage==1.0.0
... (still 75 modules)
How do I use venv so no modules are installed in the virtual environment? I didn't find any option in the documentation to help me. Also, this issue is not happening on Windows 7. Thanks!
bash caches commands found by searching the PATH. You can see the current cache by entering hash. Adding -r resets the cache. -d will delete an individual name. Sourcing the activate script should reset the cache:
# This should detect bash and zsh, which have a hash command that must
# be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then
hash -r
fi
Maybe you ran the system pip before get-pip.py. In that case hash -d pip solves the problem.

Yum crashed with Keyboard Interrupt error

I installed the newer version of python (3.2.3) than the one available in Fedora16 (python2.7)
And now yum stops working. It shows the following error.
[root#localhost yum-3.4.3]# yum
File "/usr/bin/yum", line 30
except KeyboardInterrupt, e:
^
SyntaxError: invalid syntax
Please advice as how to resolve the error. It would be helpful as I am not able to update or install any package.
Because yum does not support Python3.
You can run command vi /usr/bin/yum, change /usr/bin/python to /usr/bin/python2 in first line.
Thus you can run the command yum by Python2 instead of Python3.
Note however that this will make your setup unsupported and thus unmaintainable (as does what you did). You will likely have other similar problems in the future with other system packages.
If you want to use an alternative Python installation, consider installing it into /usr/local, /opt or using pyenv.
This issue happens when user upgrades to python3, Just simply edit the file --> /usr/bin/yum and change to first line to --> "#!/usr/bin/python2"
The above solution wouldn't solve the all yum dependency problems, its better to run the below commands.
sudo ln -s /usr/local/bin/python3 /usr/bin/python3 (Mark latest python as python3)
sudo ln -sf /usr/bin/python2.7 /usr/bin/python (nake 2.7 as default python)
THanks,
Daman
I'm guessing you installed Python 3.2.3 from source and used "make install" as the last command. That command has the unfortunate side-effect of replacing the system installed version command "python" with the new version. Using "make altinstall" doesn't replace "python".
The command "python" is just a symbolic link to "python2", which in turn is a symbolic link to "python2.7". You should be able to restore "python" by executing the following command:
cd /usr/bin
sudo ln -s python2 python
Thanks Damanvir! Changing the line in /usr/bin/yum worked!
This is a little off topic and might be removed but it might help someone.
These are the steps I used to install Python 3.7 on Centos and fix the yum error.
Download from https://www.python.org/
tar -xvf
./configure --enable-optimizations
make
make install
OR
make altinstall
make altinstall is used to prevent replacing the default python binary file /usr/bin/python.
cd /usr/bin
Remove the current symbolic link to the previous version
rm python
OUTPUT: rm: remove symbolic link ‘python’? y
Find the location of the new version
whereis python3.7
OUTPUT: python3: /usr/local/bin/python3.7
Verify this is correct
/usr/local/bin/python3.7 --version
OUTPUT: Python 3.7.0
Create a symbolic link to the location of the new version
ln -s /usr/local/bin/python3.7 python
python --version
OUTPUT: Python 3.7.0
Yum commands will show the following error:
File "/bin/yum", line 30
except KeyboardInterrupt, e:
SyntaxError: invalid syntax
Change the top line of this file from using python to python2
vi /usr/bin/yum
#!/usr/bin/python2
Reference: https://tecadmin.net/install-python-3-7-on-centos/
The real answer - to ensure that you are back on a supportable version of python (in the event you are looking at this for an issue with RHEL 7).
cd /usr/bin
sudo unlink python
sudo ln -s python2 python
Your yum looks for python2. Let's use 'alternatives' to switch between pythons2 and python3.
run --> sudo alternatives --config python
Enter to keep the current selection[+], or type selection number:
If you don't configure it. How to do that?
sudo alternatives --install /usr/bin/python python
/usr/local/bin/python3.8 60
sudo alternatives --install
/usr/bin/python python /usr/bin/python2 50
It's only a binary link issue. You can copy the working /usr/bin/python2 from any system and copy to current system location /usr/bin/python2
#cd /usr/bin
#ln -s python2 python

Resources