Is there any ways install packages for python2 only?
I am using the latest Kali Linux version and I want to use some old scripts
At that moment of creating these scripts (Around years 2013-2015). The script was written in Python1 or Python2 and required me to install other packages such as "dns-python"
I did try to install these packages but I had some problems as the follow:
The script is already installed and automatically patched with latest python3 (not python2)
If I run python/ python2 to the script. It got error such as "ImportError: No module named 'dns'" (even I already installed this module successfully but it only patch to Python3)
If I run python3 to the script. It got some error such as the syntax is not correct (For example, the old python version using print command without "", or when you assign value, you will use "is", instead of using "==")
So the question is how to install packages for python2 only
I am not counting the way you roll back old Kali version
Related
I have been having many issues with my python on macOS
(Im a beginner)
I want to use modules but every time I install something it says that the module doesn't exist even though its already installed I think it might be cause of the many versions of Python
python3 -- version says python 3.10.8 pip3 --version says python 3.9 (system) I have python 3.11.1 it does not work. In vscode I want to use packages I install them it says they don't exist. I change my VS-code python to all the different versions they still say they dont exist. I install the packages it says they already exist
from fastapi import FastAPI (, Request)
from fastapi import FastAPI, Request
ModuleNotFoundError: No module named 'fastapi'
I have tried using pyenv to manage versions and it says everything is on 3.11.1 but it doesn't change anything i have tried to remove the other versions of python but has been unsuccessful
Your terminal python, your vs-code terminal python and your project interpreter python could be diverse depends on how you install python.
To keep it simple, keep them watch same python.
On your terminal, go to your project root directory.
Type,
python -m virtualenv .venv
Virtualenv has created named '.venv'.
On terminal type source .venv/bin/activate to activate created python.
Now, your terminal python is same as your .venv.
Install all your dependency by hitting pip install -r requirements.txt
On your IDE, vs-code, set python interpreter to your ~/project/path/.venv/bin/python.
Now Every python see same python.
I'm trying to install packages on multiple versions of Python. I'm currently running 3.8.8, and 3.11.0.
Following this post Install a module using pip for specific python version
called
python3.11 -m pip install pandas
which results in
File "<stdin>", line 1 python3.11 -m pip install pandas SyntaxError: invalid syntax
This seems to indicate an issue with python, so I double checked that python3.11 is installed.
the python3.11 works in isolation seems to work.
I don't understand why the install command isn't working.
If you’re using Linux try just
python3 —-version
In Windows you may need to add path to folder with installed Python to PATH variable.
Check your environment variables, you could try removing the variables pointing to the 3.8 version until you get the packages you want installed.
You could also try navigating to that python 3.11 installation directly, and executing the python shell from there, then run the command.
I am working with some python program where I need to import mysql.connector. But I am facing ImportError: No module named connector. I already read answers on same issue and also explore google to find out and try some step to fix still it not fixed.
I am working on MacOS. and I guess by default python 2.7.18 is installed and also I installed python 3.8.9.
So I came to know that I have to install pip install mysql-connector for python 2.X but when I ran this in my terminal it is showing command not found: pip . Then I tried to install pip3 install mysql-connector. for python3 and it got successfully installed.
But Still problem not fixed. Any idea how to fix this?
It could be the case where you are running the Python file with the wrong Python installation. In VS Code we can choose the interpreter using which we want to run our Python file.
By default, the Python extension looks for and uses the first Python
interpreter it finds in the system path. To select a specific
environment, use the Python: Select Interpreter command from the
Command Palette (Ctrl+Shift+P).
Just choose Python 3.8.9 from the list of interpreters. For complete guide you can refer to the documentation:
https://code.visualstudio.com/docs/python/environments#_select-and-activate-an-environment
You got two Python installed in your system. Python3 and Python2.
Pip3 is just for python3.
You must use pip2 or pip2.7 for work with python2.
Search if you got the pip2 package installed is not then install it.
Python newbie here. I just bought a new Mac Book Pro (switched from Windows) and Python 2.7 is already installed on it. I want to install 3.6 side by side and choose between the two versions. I found a great tutorial located here http://joebergantine.com/articles/installing-python-2-and-python-3-alongside-each-ot/ but I'm confused on one of the command line operations. Under Python 2 Installation it says:
Install Python 2 from the latest Python.org package. This allows you to run python2 and pip. After this installation Python 2.x will be accessible at /Library/Frameworks/Python.framework/Versions/2.7/bin/.
Once the Python 2 package is installed, install virtualenv for Python
2 for the User only. When specifying the User installation, Python
packages are then accessible at ~/Library/Python/2.7/bin. Specifying
the User installation doesn't automatically add virtualenv to the
system path which we will do manually in the next step via an alias.
This is what allows Python3 and Python2 to run alongside each other:
$ pip install --user virtualenv
Do I have to be in the ~/Library/Python/2.7/bin directory when I run this command or the /Library/Frameworks/Python.framework/Versions/2.7/bin/ directory? I'm confused because I don't know where the former directory is coming from.
Why not using pip for python 2.7 and pip3 for python 3.6?
If it says pip3 is not installed you can use sudo apt-get install pip3
then you can use pip3 for python 3.6 and pip for python2.7 for installing packages for respective versions
I faced the exact error, in the exact situation about 2 years ago. The solution to your issue is pyenv. I was able to run multiple versions of python inside different folders of the same directory. It truly was a very nice solution.
Hope this helps.
I'm not overly familiar with Linux and am trying to run a Python script that is dependent upon Python 3.4 as well as pymssql. Both Python 2.7 and 3.4 are installed (usr/local/lib/[PYTHON_VERSION_HERE]). pymssql is also installed, except it's installed in the Python 2.7 directory, not the 3.4 directory. When I run my Python script (python3 myscript.py), I get the following error:
File "myscript.py", line 2, in
import pymssql
ImportError: No module named 'pymssql'
My belief is that I need to install pymssql to the Python 3.4 folder, but that's my uneducated opinion. So my question is this:
How can I get my script to run using Python 3.4 as well as use the pymssql package (sorry, probably wrong term there)?
I've tried many different approaches, broken my Ubuntu install (and subsequently reimaged), and at this point don't know what to do. I am a relative novice, so some of the replies I've seen on the web say to use ENV and separate the versions are really far beyond the scope of my understanding. If I have to go that route, then I will, but if there is another (i.e. easier) way to go here, I'd really appreciate it, as this was supposed to just be a tiny thing I need to take care of but it's tied up 12 hours of my life thus far! Thank you in advance.
It is better if when you run python3.4 you can have modules for that version.
Another way to get the desire modules running is install pip for python 3.4
sudo apt-get install python3-pip
Then install the module you want
python3.4 -m pip install pymssql
The easiest way is to use virtual environments instead of system paths or environment scripts. See official Python package installation guide.
All you need to do is to
# Create fresh Python environemnt
virtualenv -p python3.4 my-venv
# Activate it in current shell
source my-venv/bin/activate
# Install packages
pip install mysqlclent
Note that mysqlclient is Python 3.x compatible version.