I just want to: import numpy as np
from my Pycharm console.
I have set up virtual environments.
I can: import numpy as np in my .py code in my projects.
Is there a way to point my console to a virtual environment?
I know I was able to import numpy as np from my console in the past. I do not know how I broke this or how to fix it.
Related
Model works pretty fine on my pc using VS Code. Once I create an exe with pyinstaller and try to run the .exe nothing works. A small window appears for 1 sec and nothing else. I also tried some tk msg box and nothing happens.
Here are the imports of my main :
import csv
import os
import openpyxl
import sft_gen
from ortools.sat.python import cp_model
The imports of my 2nd file (sft_gen):
import csv
from tkinter import Tk
from tkinter.filedialog import askopenfilename
When I run the .exe in the cmd prompt I get :
Error msg in prompt
Edit.1. : After testing, found out that :
from ortools.sat.python import cp_model
is the reason why the .exe fails to execute.
What could be the solution to this? I really want to deploy my CP model to other users... In the meantime I'll try other .exe apps like py2exe and mention here if I have any success with it.
This was asked before.
From what I understand, pyinstaller does not support python module using native libraries.
My company has a large Git repository that is actively being developed (call it really-big-repo). I would like to use the reticulate package to call some of those python functions in R. Apologies in advance as I still try to get my arms around both python and git.
Single python files can be called using reticulate::source_python("flights.py") (see here). However, the python script I would like to imports modules that are from other parts of the repository. For example, the file that I would like to source great_python_functions.py looks like this:
import datetime
import json
import re
import requests
from bs4 import BeautifulSoup
from SomeRepoDirectory import utils
from SomeRepoDirectory.entity.models import Entity, EntityAlias, EntityBase, Subsidiary
import SomeRepoDirectory.entity.wikipedia
from SomeRepoDirectory.io.es import es_h
...
To further complicate it, the repo is pretty large and this file is just a small part of it. I'm not sure it is wise to load ALL of the repo's functions into my R environment.
And one more bonus question. I really would like to access the functions that are on a branch of the repo, not master. I've cloned the repository to a different directory than my R project using git clone git#github.com:my-company-name/really-big-repo.git
Here are the following steps you can try, but gotta say this is going to be complicated, might I say learning python might be easier :p
Like you said you have cloned the repository:
cd ./cloned_repo
conda activate your_vitual_env
git checkout feature/branch
python setup.py develop # this will install the pkg in virtual env, you can also use install instead of develop
Now in your R, use the virtual env in which you installed the repo, in my example I am using conda env, so you can use: reticulate::use_condaenv('your_virtual_env') and then you should be able to use those functions.
Also, in my experience intermingling python and R has caused a lot of pain for production development especially with package management. So I will advise some caution.
I have created the static build of jupyter lite while running seaborn library example code in jupyter lite tool i am getting this error : seaborn module not found.
First of all import matplotlib library then import seaborn library like,
from matplotlib import pyplot as plt
import seaborn as sn
(plt and sn is like rename or short name you can write anything like this place)
Add this at the beginning of your notebook
import piplite
await piplite.install('seaborn')
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
Sample notebook image
I'm working on a project that involves experimenting with Arduino Mega and I'm learning about it from this book https://books.google.co.uk/books/about/Python_Programming_for_Arduino.html?id=O0PfBgAAQBAJ&printsec=frontcover&source=kp_read_button&redir_esc=y#v=onepage&q&f=false
I'm in a stage where I need to import pyfirmata library but for whatever reason it keeps throwing an import error.
I installed the library using pip3 and when that didn't help I built it from source therefore I'm quite confident that I've got it in my system. I even got a file path where it is installed. Within my Python site-packages directory.
The book is favouring Python 2.7 but I figured I can make this work in Python 3 as well. I tried import pyfirmata, from pyfirmata import Arduino and in both cases I get import error.
It shouldn't be that hard to get this to work. What should I try ?
#!/usr/bin/python
# Import required libraries
import pyfirmata
from time import sleep
I also tried replacing the first line with the exact file path of the directory but no effect.
you did everything needed with python but you also need to open Arduino IDE and press files, examples, Firmata, StandardFirmata then transfer the code to your board. Your board will now easily communicate with Python through the module Pyfirmata.
I installed PyQT4 in Mac OS X El Capitan for Python 3 using the instructions given in this answer. The instructions gave the following commands:
brew install python3
brew install qt
brew install sip --with-python3
brew install pyqt --with-python3
which I run with no problems at all. I then added this line to my .bashrc file:
PYTHONPATH=/usr/local/lib/python3.3/site-packages:$PYTHONPATH
I verified Python 3 was running correcly. I also correctly evaluated the following code within Python 3:
import PyQT4
Now, when I try to run this simple program, nothing happens:
import sys
from PyQt4 import QtGui
app = QtGui.QApplication(sys.argv)
window = QtGui.QWidget()
window.show()
After running it, no window opens and nothing happens. I get no error or warning messages. Any ideas of what's going on in here?
This is correct. When you run your code, nothing is supposed to happen, and the application should immediately exit without any errors. Your example translated to C++ will behave identically, too.
Perhaps you wished to spin the event loop? app.exec() will do that.