How to "install" a python program? [closed] - python

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 11 months ago.
Improve this question
this is a pretty basic question but I'm not really finding any answer, maybe my keywords are wrong...
I've been programming in Python for a little while now and I made a few scripts that are good enough to be deployed in the department where I am working. So... Am I going to have to make everyone install Python on their machines, and then go through the tedium to install all the modules I use in the scripts with pip, or is there a better solution? Obviously I have zero experience with this, so far I've only been working on Visual Studio and running my scripts from there. I would appreciate a couple pointers, the topic is very broad and I feel lost.

It's possible to create a module, as if it's intended for pip, that you do not publish on PyPI, but allow people to install locally.
For example, observe this project on GitHub: pyjokes. It's available on PyPI so you can pip install it. But you can also download the repo and install from source. This would install it as if you'd installed it using pip (because pip is just a wrapper for "download this project and run the installer").
The procedure for installing this project from source would be:
git clone https://github.com/pyjokes/pyjokes
cd pyjokes
sudo python3 setup.py install # python 3
sudo python setup.py install # python 2
Take a look at the way the project is laid out. The essentials are the setup.py file and the __init__.py in the pyjokes folder. That should be enough to make your project installable locally.
Then you can distribute the code (perhaps a private github or bitbucket repository), and use the README to describe the installation instructions.
Note: I've described a Linux installation process, but I'm fairly sure it works the same on Mac too. I'm not sure about Windows.

Python official docs have a lot of info about this.
For 3.x.x Setup script
For 2.7.x Built dist

Related

Unable to import libraries in python even though i have the libraries installed [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 days ago.
Improve this question
I can't import libraries in python that I have installed using pip
as shown here.
Even other libraries such as PySimpleGui and PyGame don't work when I try to import them.
I have tried uninstalling and reinstalling the libraries and I am sure they are installed on my computer.
To sort this out, you need to establish two things:
where you (i.e. pip) installed the packages, and
where Python is looking for them
You can find where pip installed a package with:
pip show PACKAGE # e.g. pip show flask
Obviously, if you install using pip3 install flask, you will need to use:
pip3 show flask
Now you need to see which Python you are running and where it is looking for its packages:
import sys
print(sys.executable) # show which Python we are running
print(sys.path) # show where it is looking for packages
Hopefully you will see you are not installing into the Python interpreter you are using.
I think you might have installed them under a different folder or space than what you need. For example the code below installs the library at your current space, while simply pip3 install pygame might be somewhere else.
python3 -m pip3 install pygame

Python Module Not Importing in pycharm [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 26 days ago.
Improve this question
I am using Windows.
I just installed PyCharm and Conda. I also installed some modules via the command prompt.
I am attempting to import the 'requests' module.
This is what the Python Console says when I type in 'import requests':
ModuleNotFoundError: No module named 'requests'
Why is PyCharm not locating this 'requests' module? How do I get the module into the correct location to be imported?
Since you specifically stated: "Python Console says when I type in 'import requests'" it makes me feel like it's not an IDE/PyCharm issue, rather just an install/env issue. The Python environment does not have the requests module installed. It needs to be installed before you can import it.
More info on requests from on PyPi
Installing it is different depending on your environment and project structure.
For example, a basic install would be: pip install requests or python -m pip install requests
Or, depending on your configuration, perhaps pip3 install requests or pip install --user requests or poetry add requests etc etc all depending on your project environment.
Overall, as a side note, Python dependencies can be a nightmare if you are doing everything system-wide and working with different projects. It's highly suggested for each Python project to have its own virtual environment. An easy way to manage dependency versions and handle virtual environments is by using poetry which can manage these things in a config file + handle version locking. It'll solve these types of issues and ensure your project/dependencies can work properly on different systems.
Assuming you used pip to install the module, you can check if it is installed at all by typing "pip list" in the command prompt and then look for the module name and version.
If it does show up, go to PyCharm and go to:
File->Default Settings->Project Interpreter
If it doesn't show up there, click the +-button and then you should be able to add the packages you want.

Unable to import a library into VS code [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 1 year ago.
Improve this question
I installed pywhatkit, and it's stored along with other packages in my python3.8 file. However, I am not able to import it to VS code or any other IDEs. I tried installing tkinter. But I facing the same issue again. What should I do ?
Sometimes VS Code does this. You should install a library, after that just restart VS Code and the problem should be solved.
However, if the problem still occurs, it will be due to the Python version.
You are using Python 3, the issue is most likely that when you installed pywhatkit and tkinter you used the pip install library command, which will only install them for Python 2. To install the libraries for Python 3 just use the pip3 install library command in place of pip.
Make sure you have selected the right python interpreter. The Status Bar always shows the current interpreter:
Inspect whether you can find the packages you want to import in this environment.
Inspect where the packages you have installed through pip: pip show xxx.

Dealing with module dependency troubles [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I am trying to install lightgbm using conda. I successfully downloaded the only version I saw on the cloud(2.2.1) and saw that it forced me to downgrade my mkl. I thought this would be ok, however, when I did this, it broke some other essential functionality (a matplotlib function stopped working).
I was wondering how I might resolve this issue? Also is there a general strategy people tend to use when dealing with this whack-a-mole type dependency problem? Is there something simple that can be done to handle this? Thanks in advance!
The general strategy people use for this problem is working with different environments. When you use different environments for projects, you can install packages for each project you work on seperately, and you will not get into trouble with packages not working anymore for your other projects. It works pretty simple and avoids dependency problems.
To create a new environment use: conda create --name env_name python=requiredpythonversion
Then you should activate your newly created environment: activate env_name
After which you can install to it the packages your project requires: conda install PACKAGENAME, in your case that would be conda install lightgbm
A great tutorial on how to work with python environments using conda (You could also use pip and venv's, but since you seem to be using conda already I assume you want to proceed with that), can be found Here. I recommend you follow it, it will probably answer all the remaining questions you have about package management, and then you will be good to go =)

Mercurial and python 2.6 [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I try to install mercurial on a centos vps-server with "yum install mercurial" but it says it needs python2.4 in order to install it. I have python2.6 installed. Is there a way to get past this?
You should not have messed with your system Python --
it is incrdible you can still login at all. Python 2.4 is ancient, but it is what is used in a lot of CentOS versions in the wild - what is installed by it's package management. Maybe you had installed a ",meta package" taht upgrades the system Python to 2.6, along with everything that depends on it (yum included).
Anyway, 2.4 would be sub-optimal to install mercurial.
Since your system is a mess already, you can simply easy_install mercurial into your system Python instead of trying to use yum for it.
"sudo easy_install mercurial" -- if you don't have easy_install, try "yum install setuptools" first. If this does not work, search on pipy.python.org for setuptools, install it manually - -and think seriously on rebuilding this machinne - you will have to do it soon.

Categories

Resources