Why Python repo is not installed in WSL? - python

From my WSL terminal
pip install schemathesis
Requirement already satisfied: schemathesis in /home/milenko/.local/lib/python3.8/site-packages (3.9.7)
Requirement already satisfied: hypothesis_jsonschema>=0.20.1 in /home/milenko/.local/lib/python3.8/site-packages (from schemathesis) (0.20.1)
Requirement already satisfied: requests<3.0,>=2.22 in /usr/lib/python3/dist-packages (from schemathesis) (2.22.0)
Requirement already satisfied: pytest>4.6.4 in /home/milenko/.local/lib/python3.8/site-packages (from schemathesis) (6.2.5)
Requirement already satisfied: pytest-subtests<1.0,>=0.2.1 in /home/milenko/.local/lib/python3.8/site-packages (from schemathesis) (0.5.0)
When I try
:/mnt/c/Users/v-mimaholmes$ schemathesis
I got
schemathesis: command not found
If I try what Tzane suggested
python3 -m schemathesis
/usr/bin/python3: No module named schemathesis.__main__; 'schemathesis' is a package and cannot be directly executed
Outout from pip freeze
requests-unixsocket==0.2.0
schemathesis==3.9.7
SecretStorage==2.3.1
Why?
I do not have .local/lib.

On WSL the install location for the schemathesis -script is not in $PATH as Shinra tensei correctly assumed. I tried installing it myself on WSL Ubuntu and got the following:
The script schemathesis is installed in '/home/taneli/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
and got the same error as you. After adding ~/.local/bin to $PATH it now works as intended:
export PATH=$PATH:~/.local/bin
Not a linux wizard so I followed this about the appending to $PATH: https://unix.stackexchange.com/a/26059

Related

virtualenv env bash: virtualenv: command not found

I have a problem each time I want to start my VM even after Installing on windows
`
$ pip install virtualenv
Collecting virtualenv
Using cached virtualenv-20.16.6-py3-none-any.whl (8.8 MB)
Requirement already satisfied: platformdirs<3,>=2.4 in c:\users\samib\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (from virtualenv) (2.5.2)
Requirement already satisfied: distlib<1,>=0.3.6 in c:\users\samib\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (from virtualenv) (0.3.6)
Requirement already satisfied: filelock<4,>=3.4.1 in c:\users\samib\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (from virtualenv) (3.8.0)
Installing collected packages: virtualenv
WARNING: The script virtualenv.exe is installed in 'C:\Users\samib\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed virtualenv-20.16.6
`
I have the error
virtualenv env bash: virtualenv: command not found
I tried to uninstall and install again but I have the same issue

Create Virtual Environment The system cannot find the path specified

I want to active venv in new folder , when i write "D:\pythonproject\first_django>env\Scripts\activate" in cmd I get " The system cannot find the path specified."
also I installed venv , when I run this command "pip install virtualenv" in cmd get "Requirement already satisfied: virtualenv in c:\users\sam\appdata\local\programs\python\python310\lib\site-packages (20.13.0)
Requirement already satisfied: filelock<4,>=3.2 in c:\users\sam\appdata\local\programs\python\python310\lib\site-packages (from virtualenv) (3.4.2)
Requirement already satisfied: distlib<1,>=0.3.1 in c:\users\sam\appdata\local\programs\python\python310\lib\site-packages (from virtualenv) (0.3.4)
Requirement already satisfied: six<2,>=1.9.0 in c:\users\sam\appdata\local\programs\python\python310\lib\site-packages (from virtualenv) (1.16.0)
Requirement already satisfied: platformdirs<3,>=2 in c:\users\sam\appdata\local\programs\python\python310\lib\site-packages (from virtualenv) (2.4.1)"
can any one tell me what's problem?
I use win11 and python 3.10
Follow the below steps :
To create virtual environment
py -m venv env
To activate it
env\scripts\activate
Then proceed with your pip installations in a virtual environment.

How libraries work? Trying to install mouseinfo

I'm trying to create a script for AutoKey (Linux) that uses the 'mouseinfo' module. I did:
pip3 install mouseinfo
I ran this line while I use in
~/.config/autokey/data/My_Scripts
but when I try to
import mouseinfo
in my python script, it seems it can't find it.
I don't really know how the python libraries are organised and how to properly use them.
python3 -m site
sys.path = [
'/home/myusr/.local/lib/python3.6/site-packages',
'/usr/lib/python36.zip',
'/usr/lib/python3.6',
'/usr/lib/python3.6/lib-dynload',
'/usr/local/lib/python3.6/dist-packages',
'/usr/lib/python3/dist-packages',
]
USER_BASE: '/home/myusr/.local' (exists)
USER_SITE: '/home/myusr/.local/lib/python3.6/site-packages' (exists)
ENABLE_USER_SITE: True
and after
cd /home/myusr/.local/lib/python3.6/site-packages
ls
I get a list of packages and I can see mouseinfo there. What's next?
which python3
/usr/bin/python3
Another try:
sudo apt-get install python3-venv
python3 -m venv env
source env/bin/activate
Successfully installed mouseinfo-0.1.3
pip3 install mouseinfo
Screenshot
and as you can see, the module is installed (I think).
Still, nothing.
I'm on Reolith Linux (Ubuntu latest version), using ZSh and Vim (and Python 3, of course), if it matters.
What's next?
Edit: I tried to install Xlib as well, same story, can't import it. I am obviously doing something wrong due to my Python ignorance, but can't figure out what.
Edit 2: installed virtualenv plugin for Vim, but :VirtualEnvList return 'Not an editor command'.
Edit 3: activated venv and also:
source env/bin/activate
~/.config/autokey/data/My_Scripts
pip install mouseinfo
Requirement already satisfied: mouseinfo in ./env/lib/python3.6/site-packages (0.1.3)
Requirement already satisfied: python3-Xlib; platform_system == "Linux" and python_version >= "3.0" in ./env/lib/python3.6/site-packages (from mouseinfo) (0.15)
Requirement already satisfied: Pillow>=4.0.0; python_version == "3.6" in ./env/lib/python3.6/site-packages (from mouseinfo) (7.1.1)
Requirement already satisfied: pyperclip in ./env/lib/python3.6/site-packages (from mouseinfo) (1.8.0)
pip3 install mouseinfo
Requirement already satisfied: mouseinfo in ./env/lib/python3.6/site-packages (0.1.3)
Requirement already satisfied: pyperclip in ./env/lib/python3.6/site-packages (from mouseinfo) (1.8.0)
Requirement already satisfied: Pillow>=4.0.0; python_version == "3.6" in ./env/lib/python3.6/site-packages (from mouseinfo) (7.1.1)
Requirement already satisfied: python3-Xlib; platform_system == "Linux" and python_version >= "3.0" in ./env/lib/python3.6/site-packages (from mouseinfo) (0.15)
It seems that I can import the module after running python3 in the terminal. Problem is with Vim probably. Any ideas?
As your default pip3 and python3 are in different locations you can try installing the package by first invoking your desired python installation and calling out to pip
python3 -m pip install mouseinfo
I decided to give up on Vim and use Visual Studio Code, and to use pyautogui's position instead. This way it works.

Locate where conda placed a python package I installed

A python newbie question:
On an Ubuntu system, I installed a python package using sudo pip install. (The package is called hlmm)
I'm using the miniconda3 environment and the only environment variable specified in my .bashrc is:
export PATH="/home/<my_username>/miniconda3/bin:$PATH"
Now I want to run a test script from the package I installed, which is located under a tests folder relative to where that package was installed.
I used pip list | xargs -exec pip show to look for the location of that package but it doesn't show up.
I also tried in python to import the package, using:
import hlmm
And I'm getting:
>>> import hlmm
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'hlmm'
If I redo sudo pip install hlmm I get:
Requirement already satisfied: hlmm in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied: scipy in /usr/local/lib/python2.7/dist-packages (from hlmm)
Requirement already satisfied: numpy in /usr/local/lib/python2.7/dist-packages (from hlmm)
Requirement already satisfied: pysnptools in /usr/local/lib/python2.7/dist-packages (from hlmm)
Requirement already satisfied: pandas>=0.19.0 in /usr/local/lib/python2.7/dist-packages (from pysnptools->hlmm)
Requirement already satisfied: pytz>=2011k in /usr/local/lib/python2.7/dist-packages (from pandas>=0.19.0->pysnptools->hlmm)
Requirement already satisfied: python-dateutil>=2.5.0 in /usr/local/lib/python2.7/dist-packages (from pandas>=0.19.0->pysnptools->hlmm)
Requirement already satisfied: six>=1.5 in /usr/lib/python2.7/dist-packages (from python-dateutil>=2.5.0->pandas>=0.19.0->pysnptools->hlmm)
And, I do see the hlmm folder under /usr/local/lib/python2.7/dist-packages, but cannot find that tests folder:
ls -1 /usr/local/lib/python2.7/dist-packages/hlmm
__init__.py
__init__.pyc
hetlm.py
hetlm.pyc
hetlmm.py
hetlmm.pyc
How do I find its location? And, is the package really successfully installed despite the import hlmm error?
This was getting too long to be a comment, so I'm posting it as an answer.
Yeah, it sounds like pip installed it from your python 2.7 version. You should read this post: How to install PyPi packages using anacaonda conda command and this article: https://www.anaconda.com/using-pip-in-a-conda-environment/ to decide how you want to proceed. I generally use conda when possible, and pip if conda doesn't have a build. You might want to run pip uninstall hlmm then activate your conda env and use pip3 install hlmm. But, I think you should decide the best way to manage your environments after doing research.

Module path order in virtualenv

I noticed a strange phenomenon related to dist-packages paths. The order of my paths in my system-wide installation of python 3 (simply running python3 and then printing sys.path) is as follows:
/usr/local/lib/python3.4/dist-packages
/usr/lib/python3/dist-packages
i.e. the path in local is preferred. However, creating a virtual environment and running python3 after activating the environment gives:
/usr/lib/python3/dist-packages
/usr/local/lib/python3.4/dist-packages
The order is clearly reversed. Yet, pip still searches local first, which results in a different version of a library seen by pip dependencies and a different one used when importing.
Can someone explain the discrepancy?
EDIT:
When the virtualenv is activated, the pip used is the one installed in the virtualenv:
pip 9.0.1 from ~/.virtualenv/python3/lib/python3.4/site-packages (python 3.4)
and yet, despite the path pointing first to dist-utils in /usr/lib, it does resolve dependencies with what's in /usr/local/lib:
pip3 install --upgrade setuptools
Requirement already up-to-date: setuptools in ./.virtualenv/python3/lib/python3.4/site-packages
Requirement already up-to-date: appdirs>=1.4.0 in ./.virtualenv/python3/lib/python3.4/site-packages (from setuptools)
Requirement already up-to-date: packaging>=16.8 in /usr/local/lib/python3.4/dist-packages (from setuptools)
Requirement already up-to-date: six>=1.6.0 in ./.virtualenv/python3/lib/python3.4/site-packages (from setuptools)
Requirement already up-to-date: pyparsing in /usr/local/lib/python3.4/dist-packages (from packaging>=16.8->setuptools)

Categories

Resources