I've installed mongoctl according to Mongolab's simple instructions, but I can't do anything with the installed package because which mongoctl resolves to nothing.
The site makes it look like pip installs some kind of command line tool, but it seems like it just installs the python package, which would be fine if all of the documentation didn't treat mongoctl as a command line tool.
What's going on?
You can add the following option to your install command to ensure that "mongoctl" exe goes to /usr/local/bin
--install-option="--install-scripts=/usr/local/bin"
Since mongoctl is already installed on your mac, you will probably need to add a --upgrade and a --force-reinstall
So try the following
sudo pip install mongoctl --install-option="--install-scripts=/usr/local/bin" --upgrade --force-reinstall
What OS are you using?
'mongoctl' should be in /usr/local/bin. Check to make sure that directory is in your PATH
-will
Related
I have installed Anaconda since it was recommended to use in the OpenMDAO's website. After that I typed pip install 'openmdao[all]' as instructed. However I get an error message saying, "ERROR: Invalid requirement: "'openmdao[all]'"" I was wondering how can I solve this issue. I have no knowledge about the Python or anaconda therefore I don't have a clue what to do about this situation. I searched the internet however I didn't find a solution to this. Thanks in advance!
It's possible you're running the wrong pip executable. Try which pip - it should be located under your home directory instead of a system path such as /bin/pip or /usr/bin/pip.
Make sure you've created and activated an environment in Anaconda:
conda create -n myenv pip
conda activate myenv
python -m pip install 'openmdao[all]'
That command sequence will give the highest chance of success. The single quotes are required for shells like zsh.
Remove the single quotes:
pip install openmdao[all]
Fair Warning: I am extremely new to python, so please excuse any dumb mistakes I make =)
I would like to be able to open/close/manipulate/read Word documents (docx files) on my Mac using Python. The python-docx module looked really useful, so I have been trying to install it on my system, to no avail.
Here's what I've done so far:
Checked that I do indeed have python installed using the python --version command in terminal. I have version 3.7.0, so all good there.
Checked that I do indeed have pip installed - I was able to use pip install and pip uninstall commands, so all good. I also upgraded my pip version using pip install --upgrade pip to pip-19.1.1
Following the online documentation (see here), I tried pip install python-docx. This seemed to work just fine, and after the progress bar loaded all the way I saw:
Successfully built python-docx
twisted 18.7.0 requires PyHamcrest>=1.9.0, which is not installed.
Installing collected packages: python-docx
Successfully installed python-docx-0.8.10
I wasn't completely sure what pyhamcrest was, but I installed it anyway just to be safe using pip install pyhamcrest
As other sites suggested, I also tried to install Pillow, lxml, and python-dateutil using their respective install commands, and in each case saw the Requirement already satisfied: message, with an anaconda path listed.
Frustrated, I also tried easy_install python-docx, the manual version, and even pip install docx . In all cases, when I run IDLE and type from docx import Document or just import docx, I get the following message in the shell:
`Traceback (most recent call last):`
`File "/Users/[my_name]/Desktop/Medical.py", line 3, in <module> `
`import docx`
`ModuleNotFoundError: No module named 'docx'`
Could anyone help point me in the right direction? Thank you very much.
The Anaconda Python distribution has its own system of installation of packages.
After the installation of Anaconda, the variable $PATH has been modified so that anaconda python was the first, and OsX's python in the last position.
If you type "python" in a shell will execute the anaconda python, instead of the standard OsX python (which is 2.7, not 3.x).
Following the instructions of the package python-docx, you have installed it using pip, which is the default method for installing packages, but this method is not valid for Anaconda Python. So, you finished installing python-docx for the python 2.7 of OsX.
To install packages for anaconda, you must run the command
conda install <package>
The python-docx module for anaconda can be found in a separated repository called conda-forge; typing the command
conda install -c conda-forge python-docx
you will install the package and the requested dependencies.
Other useful commands are:
anaconda-navigator for exploring the Anaconda system
anaconda-project for managing projects with anaconda
idle3 for Anaconda Python shell.
Before start coding, run anaconda-navigator and take a look at the 'Learning' section.
For a better experience, I suggest PyCharm IDE for Anaconda from JetBrains.
1) I installed virtualenv using pip.
2) I ran the command virtualenv venv
3) Then I ran source venv/bin/activate but it says that there is no such file or directory.
When I cd into venv/bin I find 3 things - python, python 2.7, and python 3.5. Does anyone know the problem?
i have had the same problem. and what i did is just run the command
virtualenv env
again. And then more files were generated under directory env/bin, including the activate file. it's so weird.
I solved the similar problem running python3.7 -m venv venv, you can change for your version of python that is installed in your enviroment.
According to Python doc, the installation step is
$ python3 -m pip install --user virtualenv
$ python3 -m venv env
The last command gives a warning message,
The virtual environment was not created successfully because ensurepip is not
available. On Debian/Ubuntu systems, you need to install the python3-venv
package using the following command.
apt-get install python3-venv
You may need to use sudo with that command. After installing the python3-venv
package, recreate your virtual environment.
$ sudo apt-get install python3-venv
Now, activate is available.
I solved a similar problem by naming it venv2 when I ran virtualenv. I already had a virtual environment named venv for another project. This allowed me to proceed.
I experienced this problem when using the --upgrade option. Removed the option, and all ran as expected.
I double it is caused by some networking issue, I run it twice to get 'activate' script installed. Maybe first it can't connect to some source so it just abort installation.
I had this happen on rasbian when I hadn't installed python3-pip before creating the venv.
I'm trying to wrap my head around virtualenv and pip still.
If I use pip to install a library, it doesn't matter where I 'cd' to, because it installs the libraries in the same place right (which i dont even know where that is)? So I guess my question is, when I install something with pip, how do I make sure it only installs that library inside of my virtual environment? Do I need to cd to that directory first? or is there a command I'm supposed to use with pip to make sure it only installs to the virtualenv project I'm working in?
Activate virtualenv first:
source virt_name/bin/activate
Then after that, install the libraries:
pip install module_name
Note: Don't use sudo with pip because sometimes it will assume you want to install in /usr/local/lib/site-packages.
Generally speaking, if you do not use virtualenv --system-site-packages to create your virtualenv, you should be only working with your per-environment packages.
Providing you run the activate script before installing anything.
i.e. Do the following, if you want to install something in your virtualenv.
Run activate script
Windows: [ve_directory]\Script\activate.bat
Linux: source [ve_directory]/bin/activate
pip install [your requirements]
I think it doesn't matter where your current working directory is.
Reference:
http://www.virtualenv.org/en/latest/#the-system-site-packages-option
When you create a new environment with virtualenv, among other things it creates a bash script venv/bin/activate (where venv is the folder you specified when you created the environment; libraries are located there as well, by the way). When you run it in your shell the environment variables become arranged so that pip installs new libraries in this environment's folder. See virtualenv docs for details, section "activate script".
tow-81-235:Projects pessimisticoptimism$ mkvirtualenv development
-bash: mkvirtualenv: command not found
tow-81-235:Projects pessimisticoptimism$ sudo pip install virtualenvwrapper
Password:
Requirement already satisfied (use --upgrade to upgrade): virtualenvwrapper in /Library/Python/2.7/site-packages
Requirement already satisfied (use --upgrade to upgrade): virtualenv in /Library/Python/2.7/site-packages (from virtualenvwrapper)
Requirement already satisfied (use --upgrade to upgrade): virtualenv-clone in /Library/Python/2.7/site-packages (from virtualenvwrapper)
Cleaning up...
tow-81-235:Projects pessimisticoptimism$ mkvirtualenv development
-bash: mkvirtualenv: command not found
Why am I getting this error? I have virtualenv and virtualenvwrapper installed. I'd like to use mkvirtualenv and workon. I find it odd that virtualenv is working, but virtualenvwrapper isn't.
1st, ensure you're installing with sudo:
sudo pip install virtualenvwrapper
2nd, append the following lines to your .bashrc file (with nano ~/.bashrc):
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
3rd, reload your profile
source ~/.bashrc
Summary
I'm on a Mac and my answer is similar to #Ramces answer except it was with bash_profile. I just want to elaborate a little further for Mac users to be aware that there's a lot of different profiles including:
.bashrc
.bash_profile
.profile
Some files like .profile do not take precedence over .bash_profile (if it exists) and will then be ignored. If you successfully do the below steps and get a virtual env working, but then close out your terminal and 'workon command not found', then you need to setup for the correct profile. For a detailed answer, see here
Install Steps:
sudo pip install virtualenv
Installs virtualenv (allows you to separate your envrionments)
sudo pip install virtualenvwrapper
Installs virtualenvwrapper (allows you to use the 'workon' command)
nano ~/.bash_profile
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
source ~/.bash_profile
Reloads the profile. Going forward you only need step 5 (to create new environments) and step 6 (to run environments)
mkvirtualenv my_env
This creates your virtual environment (this example is with 'my_env')
workon my_env
This lets you work on a specific environment (this example is with 'my_env')
After installing the virtualenvwrapper package using pip, you also have to do some initialisation/set your preferences. See the introduction in the virtualenvwrapper docs.
Most relevant for finding the commands should be sourcing the virtualenvwrapper script into your shell. In the docs it is mentioned as
$ source /usr/local/bin/virtualenvwrapper.sh
You still have to adjust the path to your setup. My guess for your Mac would be:
$ source /Library/Python/2.7/site-packages/virtualenvwrapper.sh
Simple process
sudo apt-get install python-pip(if pip is not installed)
sudo pip install virtualenv
Create a dir to store your virtualenvs
mkdir ~/.virtualenvs
sudo pip install virtualenvwrapper
Run following command
export WORKON_HOME=~/.virtualenvs
Add virtualenvwrapper.sh to .bashrc
Add this line to the end of ~/.bashrc so that the virtualenvwrapper commands are loaded.
. /usr/local/bin/virtualenvwrapper.sh
you will find .bashrc.sh file in home directory by doing ctrl+h. if not then use find command to find .bashrc.sh "file ls -la ~/ | more"
Hit this command
source /usr/local/bin/virtualenvwrapper.sh
Hit this command
source ~/.bashrc
It sounds like you have multiple Python installations on your machine and virtualenvwrapper is not pointing to the right Python.
Find out which Python virtualenvwrapper is using. You get a hint where to look with which virtualenvwrapper.sh (In this case /usr/local/bin):
> /usr/local/bin/virtualenvwrapper.sh
If you don't get any return here make sure you use the correct pip when installing. The pip command might link to a different Python then you expect. Check your usr/local/bin directory for pip links (pip, pip2, pip2.7, pip3, pip3.5). It is easy to get system pip, pip2 and pip2.7 mixed up.
After you have found the Python location, add/update all paths in your .profile:
export WORKON_HOME=$HOME/venv
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python2
source /usr/local/bin/virtualenvwrapper.sh
Finally reload your profile: source ~/.profile
I am on Mac OS X 10.9.2 and for me virtualenvwrapper.sh file was present in
/usr/local/bin/virtualenvwrapper.sh
So I simply copied this into ~/.profile file:
source /usr/local/bin/virtualenvwrapper.sh
And now my ~/.profile file looks something like this:
# MacPorts Installer addition on 2014-02-23_at_17:28:39: adding an appropriate PATH variable for use with MacPorts.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.
source /usr/local/bin/virtualenvwrapper.sh
And now I am able to use virtualenvwrapper commands without any issue whatsoever
Users of the Anaconda (from Continuum) distribution of Python should note that
sudo pip install virtualenvwrapper
will be anaconda-aware. So if you
which python
that should give you an idea of where to point your virtualenv in your .bashrc and/or .profile configuration files.